Changes
This commit is contained in:
9
node_modules/mongoose/lib/drivers/node-mongodb-native/collection.js
generated
vendored
9
node_modules/mongoose/lib/drivers/node-mongodb-native/collection.js
generated
vendored
@@ -140,7 +140,7 @@ function iter(i) {
|
||||
}
|
||||
}
|
||||
|
||||
if (this.buffer) {
|
||||
if (this._shouldBufferCommands() && this.buffer) {
|
||||
if (syncCollectionMethods[i]) {
|
||||
throw new Error('Collection method ' + i + ' is synchronous');
|
||||
}
|
||||
@@ -148,6 +148,9 @@ function iter(i) {
|
||||
this.addQueue(i, args);
|
||||
return;
|
||||
}
|
||||
|
||||
this.conn.emit('buffer', { method: i, args: args });
|
||||
|
||||
return new this.Promise((resolve, reject) => {
|
||||
this.addQueue(i, [].concat(args).concat([(err, res) => {
|
||||
if (err != null) {
|
||||
@@ -170,6 +173,10 @@ function iter(i) {
|
||||
}
|
||||
|
||||
try {
|
||||
if (collection == null) {
|
||||
throw new MongooseError('Cannot call `' + this.name + '.' + i + '()` before initial connection is complete if `bufferCommands = false`. Make sure you `await mongoose.connect()` if you have `bufferCommands = false`.');
|
||||
}
|
||||
|
||||
return collection[i].apply(collection, args);
|
||||
} catch (error) {
|
||||
// Collection operation may throw because of max bson size, catch it here
|
||||
|
||||
Reference in New Issue
Block a user