This commit is contained in:
2020-08-20 11:44:32 +02:00
parent 4715fc1814
commit 6aceefeb2f
2891 changed files with 11239 additions and 347539 deletions

View File

@@ -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