This enables standard Promise based error handling to detect errors during collection creation (rather than having to use the callbacks). If I understand correctly, this is an API inconsistency with MongoDB.
The following fails when I expect it to work:
const db = new Db(dbPath, {});
db.createCollection('asdf', {}).then(collection => {
console.log(collection);
});
TypeError: db.createCollection(...).then is not a function
Db.createCollection()
should return aPromise
yieldingCollection
like the mongo node API does.From the example at https://mongodb.github.io/node-mongodb-native/2.2/api/Db.html#createCollection :
This enables standard
Promise
based error handling to detect errors during collection creation (rather than having to use the callbacks). If I understand correctly, this is an API inconsistency with MongoDB.The following fails when I expect it to work: