Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// See gh-3906
if (args.length > 0 &&
typeof args[args.length - 1] === 'function') {
args[args.length - 1](error);
} else {
throw error;
}
}
};
}
for (var i in Collection.prototype) {
// Janky hack to work around gh-3005 until we can get rid of the mongoose
// collection abstraction
try {
if (typeof Collection.prototype[i] !== 'function') {
continue;
}
} catch (e) {
continue;
}
iter(i);
}
/**
* Debug print helper
*
* @api public
* @method $print
*/
try {
return collection[i].apply(collection, args);
} catch (error) {
// Collection operation may throw because of max bson size, catch it here
// See gh-3906
if (args.length > 0 &&
typeof args[args.length - 1] === 'function') {
args[args.length - 1](error);
} else {
throw error;
}
}
};
}
for (const i in Collection.prototype) {
// Janky hack to work around gh-3005 until we can get rid of the mongoose
// collection abstraction
try {
if (typeof Collection.prototype[i] !== 'function') {
continue;
}
} catch (e) {
continue;
}
iter(i);
}
/**
* Debug print helper
*
/**
* Called when the connection closes
*
* @api private
*/
NativeCollection.prototype.onClose = function() {
MongooseCollection.prototype.onClose.call(this);
};
/*!
* Copy the collection methods and make them subject to queues
*/
for (var i in Collection.prototype) {
// Janky hack to work around gh-3005 until we can get rid of the mongoose
// collection abstraction
try {
if (typeof Collection.prototype[i] !== 'function') {
continue;
}
} catch (e) {
continue;
}
(function(i) {
NativeCollection.prototype[i] = function() {
if (this.buffer) {
this.addQueue(i, arguments);
return;
}
/**
* Called when the connection closes
*
* @api private
*/
NativeCollection.prototype.onClose = function () {
MongooseCollection.prototype.onClose.call(this);
};
/*!
* Copy the collection methods and make them subject to queues
*/
for (var i in Collection.prototype) {
// Janky hack to work around gh-3005 until we can get rid of the mongoose
// collection abstraction
try {
if (typeof Collection.prototype[i] !== 'function') {
continue;
}
} catch(e) {
continue;
}
(function(i){
NativeCollection.prototype[i] = function () {
if (this.buffer) {
this.addQueue(i, arguments);
return;
}
// See gh-3906
if (args.length > 0 &&
typeof args[args.length - 1] === 'function') {
args[args.length - 1](error);
} else {
throw error;
}
}
};
}
for (var i in Collection.prototype) {
// Janky hack to work around gh-3005 until we can get rid of the mongoose
// collection abstraction
try {
if (typeof Collection.prototype[i] !== 'function') {
continue;
}
} catch (e) {
continue;
}
iter(i);
}
/**
* Debug print helper
*
* @api public
* @method $print
*/
* @api private
*/
NativeCollection.prototype.onClose = function() {
MongooseCollection.prototype.onClose.call(this);
};
/*!
* Copy the collection methods and make them subject to queues
*/
for (var i in Collection.prototype) {
// Janky hack to work around gh-3005 until we can get rid of the mongoose
// collection abstraction
try {
if (typeof Collection.prototype[i] !== 'function') {
continue;
}
} catch (e) {
continue;
}
(function(i) {
NativeCollection.prototype[i] = function() {
if (this.buffer) {
this.addQueue(i, arguments);
return;
}
var collection = this.collection,
args = arguments,
self = this,
try {
return collection[i].apply(collection, args);
} catch (error) {
// Collection operation may throw because of max bson size, catch it here
// See gh-3906
if (args.length > 0 &&
typeof args[args.length - 1] === 'function') {
args[args.length - 1](error);
} else {
throw error;
}
}
};
}
for (var i in Collection.prototype) {
// Janky hack to work around gh-3005 until we can get rid of the mongoose
// collection abstraction
try {
if (typeof Collection.prototype[i] !== 'function') {
continue;
}
} catch (e) {
continue;
}
iter(i);
}
/**
* Debug print helper
*
meta: meta,
result: nativeResult
};
self.trigger('afterUpdateOne', [afterHookParams], function(err) {
if (err) {
return triggerErrorHook(err, callback);
}
callback(
null, isReturnDocsOnly && !err ? updateResult.value : updateResult
);
});
};
SourceCollection.prototype.findOneAndUpdate.call(
self, filter, update, options, sourceCallback
);
});
};
afterHookParams = {
condition: filter,
replacement: update,
options: options,
result: nativeResult
};
self.trigger('afterReplaceOne', [afterHookParams], function(err) {
if (err) {
return triggerErrorHook(err, callback);
}
callback(err, isReturnResultOnly ? nativeResult : replaceResult);
});
};
SourceCollection.prototype.replaceOne.call(
self, filter, update, options, sourceReplaceCallback
);
});
};
meta: meta,
result: nativeResult
};
self.trigger(afterHookName, [afterHookParams], function(err) {
if (err) {
return triggerErrorHook(err, callback);
}
callback(
null, isReturnResultOnly ? nativeResult : updateResult
);
});
};
SourceCollection.prototype[methodName].call(
self, filter, update, options, sourceUpdateCallback
);
});
});