Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (collection) {
this.mongooseCollection = collection;
}
if (model) {
this.model = model;
}
// this is needed because map reduce returns a model that can be queried, but
// all of the queries on said model should be lean
if (this.model && this.model._mapreduce) {
this.lean();
}
// inherit mquery
mquery.call(this, this.mongooseCollection, options);
if (conditions) {
this.find(conditions);
}
}
this.mongooseCollection = collection;
}
if (model) {
this.model = model;
this.schema = model.schema;
}
// this is needed because map reduce returns a model that can be queried, but
// all of the queries on said model should be lean
if (this.model && this.model._mapreduce) {
this.lean();
}
// inherit mquery
mquery.call(this, this.mongooseCollection, options);
if (conditions) {
this.find(conditions);
}
if (this.schema) {
var kareemOptions = {
useErrorHandlers: true,
numCallbackParams: 1
};
this._count = this.model.hooks.createWrapper('count',
Query.prototype._count, this, kareemOptions);
this._execUpdate = this.model.hooks.createWrapper('update',
Query.prototype._execUpdate, this, kareemOptions);
this._find = this.model.hooks.createWrapper('find',
Query.prototype._find, this, kareemOptions);
this.mongooseCollection = collection;
}
if (model) {
this.model = model;
this.schema = model.schema;
}
// this is needed because map reduce returns a model that can be queried, but
// all of the queries on said model should be lean
if (this.model && this.model._mapreduce) {
this.lean();
}
// inherit mquery
mquery.call(this, this.mongooseCollection, options);
if (conditions) {
this.find(conditions);
}
this.options = this.options || {};
const collation = get(this, 'schema.options.collation', null);
if (collation != null) {
this.options.collation = collation;
}
}
this.mongooseCollection = collection;
}
if (model) {
this.model = model;
this.schema = model.schema;
}
// this is needed because map reduce returns a model that can be queried, but
// all of the queries on said model should be lean
if (this.model && this.model._mapreduce) {
this.lean();
}
// inherit mquery
mquery.call(this, this.mongooseCollection, options);
if (conditions) {
this.find(conditions);
}
if (this.schema) {
this._count = this.model.hooks.createWrapper('count',
Query.prototype._count, this);
this._execUpdate = this.model.hooks.createWrapper('update',
Query.prototype._execUpdate, this);
this._find = this.model.hooks.createWrapper('find',
Query.prototype._find, this);
this._findOne = this.model.hooks.createWrapper('findOne',
Query.prototype._findOne, this);
this._findOneAndRemove = this.model.hooks.createWrapper('findOneAndRemove',
Query.prototype._findOneAndRemove, this);
this.mongooseCollection = collection;
}
if (model) {
this.model = model;
this.schema = model.schema;
}
// this is needed because map reduce returns a model that can be queried, but
// all of the queries on said model should be lean
if (this.model && this.model._mapreduce) {
this.lean();
}
// inherit mquery
mquery.call(this, this.mongooseCollection, options);
if (conditions) {
this.find(conditions);
}
if (this.schema) {
this._count = this.model.hooks.createWrapper('count',
Query.prototype._count, this);
this._execUpdate = this.model.hooks.createWrapper('update',
Query.prototype._execUpdate, this);
this._find = this.model.hooks.createWrapper('find',
Query.prototype._find, this);
this._findOne = this.model.hooks.createWrapper('findOne',
Query.prototype._findOne, this);
this._findOneAndUpdate = this.model.hooks.createWrapper('findOneAndUpdate',
Query.prototype._findOneAndUpdate, this);
this.mongooseCollection = collection;
}
if (model) {
this.model = model;
this.schema = model.schema;
}
// this is needed because map reduce returns a model that can be queried, but
// all of the queries on said model should be lean
if (this.model && this.model._mapreduce) {
this.lean();
}
// inherit mquery
mquery.call(this, this.mongooseCollection, options);
if (conditions) {
this.find(conditions);
}
if (this.schema) {
var kareemOptions = { useErrorHandlers: true };
this._count = this.model.hooks.createWrapper('count',
Query.prototype._count, this, kareemOptions);
this._execUpdate = this.model.hooks.createWrapper('update',
Query.prototype._execUpdate, this, kareemOptions);
this._find = this.model.hooks.createWrapper('find',
Query.prototype._find, this, kareemOptions);
this._findOne = this.model.hooks.createWrapper('findOne',
Query.prototype._findOne, this, kareemOptions);
this._findOneAndRemove = this.model.hooks.createWrapper('findOneAndRemove',
this.mongooseCollection = collection;
}
if (model) {
this.model = model;
this.schema = model.schema;
}
// this is needed because map reduce returns a model that can be queried, but
// all of the queries on said model should be lean
if (this.model && this.model._mapreduce) {
this.lean();
}
// inherit mquery
mquery.call(this, this.mongooseCollection, options);
if (conditions) {
this.find(conditions);
}
this.options = this.options || {};
if (this.schema != null && this.schema.options.collation != null) {
this.options.collation = this.schema.options.collation;
}
if (this.schema) {
var kareemOptions = {
useErrorHandlers: true,
numCallbackParams: 1,
nullResultByDefault: true
};
this.mongooseCollection = collection;
}
if (model) {
this.model = model;
this.schema = model.schema;
}
// this is needed because map reduce returns a model that can be queried, but
// all of the queries on said model should be lean
if (this.model && this.model._mapreduce) {
this.lean();
}
// inherit mquery
mquery.call(this, this.mongooseCollection, options);
if (conditions) {
this.find(conditions);
}
if (this.schema) {
this._execUpdate = this.model.hooks.createWrapper('update',
Query.prototype._execUpdate, this);
}
}
this.mongooseCollection = collection;
}
if (model) {
this.model = model;
this.schema = model.schema;
}
// this is needed because map reduce returns a model that can be queried, but
// all of the queries on said model should be lean
if (this.model && this.model._mapreduce) {
this.lean();
}
// inherit mquery
mquery.call(this, this.mongooseCollection, options);
if (conditions) {
this.find(conditions);
}
}
// create a listener that we will use to deal with commands that need to be
// buffered because the connection hasn't happened yet
this.events = new events.EventEmitter();
this.events.setMaxListeners(0);
this.mongooseCollection = collection;
this.model = model;
// this is needed because map reduce returns a model that can be queried, but
// all of the queries on said model should be lean
if (this.model && this.model._mapreduce) {
this.lean();
}
// call the mquery constructor
mquery.call(this, collection, options);
if (conditions) {
this.find(conditions);
}
}