Still need to roll over the MongoDB driver?

Are the answers in this question relevant: How can I roll over my own Javascript MongoDB driver using bluebird?

I don’t know since it was updated, but the 2.0 JS driver for MongoDB has a property in the options promiseLibrary object: http://mongodb.imtqy.com/node-mongodb-native/2.0/api/MongoClient.html

And most methods / functions return a promise, for example, Cursor.toArray() .

However, I cannot find an example using this new option, but isn’t it easier to use:

 MongoClient.connect('mongodb://URL', { promiseLibrary: require('bluebird') }); 

Or is this definition incorrect? - In which case, how should it be correctly defined?

Update:

The code runs on io.js, so I don’t even need to specify promiseLibrary , since the driver will use ES6 promises? - However, presumably, bluebird promises is slower:

Why is the native ES6 promises slower and more memory intensive than bluebird?

Update2: I added the bluebird tag - maybe the guys working on bluebird can provide more details if the promise is really better than using MongoDB's own implementation?

+6
source share
1 answer

Do I need to prove the MongoDB driver again?

No, now they are built-in to support promised libraries like bluebird. I think we should ask the question differently though:

Is it possible to secure the MongoDB driver?

Bluebird may be better at converting the callback API to promises than the Mongo driver does internally, wrapping it much more easily. Most likely, he will promise even faster as "in previous days."

+1
source

All Articles