Changes
This commit is contained in:
31
node_modules/mongoose/lib/collection.js
generated
vendored
31
node_modules/mongoose/lib/collection.js
generated
vendored
@@ -27,10 +27,6 @@ function Collection(name, conn, opts) {
|
||||
opts.capped = {};
|
||||
}
|
||||
|
||||
opts.bufferCommands = undefined === opts.bufferCommands
|
||||
? true
|
||||
: opts.bufferCommands;
|
||||
|
||||
if (typeof opts.capped === 'number') {
|
||||
opts.capped = { size: opts.capped };
|
||||
}
|
||||
@@ -40,7 +36,7 @@ function Collection(name, conn, opts) {
|
||||
this.collectionName = name;
|
||||
this.conn = conn;
|
||||
this.queue = [];
|
||||
this.buffer = this.opts.bufferCommands;
|
||||
this.buffer = true;
|
||||
this.emitter = new EventEmitter();
|
||||
|
||||
if (STATES.connected === this.conn.readyState) {
|
||||
@@ -93,7 +89,7 @@ Collection.prototype.onOpen = function() {
|
||||
*/
|
||||
|
||||
Collection.prototype.onClose = function(force) {
|
||||
if (this.opts.bufferCommands && !force) {
|
||||
if (this._shouldBufferCommands() && !force) {
|
||||
this.buffer = true;
|
||||
}
|
||||
};
|
||||
@@ -262,6 +258,29 @@ Collection.prototype.watch = function() {
|
||||
throw new Error('Collection#watch unimplemented by driver');
|
||||
};
|
||||
|
||||
/*!
|
||||
* ignore
|
||||
*/
|
||||
|
||||
Collection.prototype._shouldBufferCommands = function _shouldBufferCommands() {
|
||||
const conn = this.conn;
|
||||
const opts = this.opts;
|
||||
|
||||
if (opts.bufferCommands != null) {
|
||||
return opts.bufferCommands;
|
||||
}
|
||||
if (opts && opts.schemaUserProvidedOptions != null && opts.schemaUserProvidedOptions.bufferCommands != null) {
|
||||
return opts.schemaUserProvidedOptions.bufferCommands;
|
||||
}
|
||||
if (conn.config.bufferCommands != null) {
|
||||
return conn.config.bufferCommands;
|
||||
}
|
||||
if (conn.base != null && conn.base.get('bufferCommands') != null) {
|
||||
return conn.base.get('bufferCommands');
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
/*!
|
||||
* Module exports.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user