Back

Explore Courses Blog Tutorials Interview Questions
0 votes
4 views
in Web Technology by (47.6k points)

I'm working with Mongoose. I have seen a lot of developers make the following command:

mongoose.Promise = global.Promise;

Then I was curious to see what is the original value of mongoose.Promise. I have entered in my editor the following command:

const mongoose = require("mongoose"); 

console.log("promise: ", mongoose.Promise);

My console returned me :

promise: function Promise() { [native code] }

Okay, so why make the command mongoose.Promise = global.Promise since the Mongoose's promise already returns a native code? I don't understand the point if someone can help us to understand, would be great,

Thanks

2 Answers

0 votes
by (106k points)

Mongoose 4 relied on its own promise implementation, mpromise.Mongoose. Promise wasn't necessarily Promise global.

0 votes
by (108k points)

If we want to use mongoose in different position inside the codes it must be seen as global mode, that's why we need to set mongoose as :

mongoose.Promise = global.Promise;

Related questions

0 votes
2 answers
0 votes
2 answers
0 votes
2 answers
asked Oct 16, 2019 in Web Technology by Sammy (47.6k points)
0 votes
1 answer

Browse Categories

...