As I looked through the source code of the find() of mongoose.js , which looks like following:
Query.prototype.find = function(conditions, callback) {
if (typeof conditions === 'function') {
callback = conditions;
conditions = {};
}
conditions = utils.toObject(conditions);
if (mquery.canMerge(conditions)) {
this.merge(conditions);
}
prepareDiscriminatorCriteria(this);
try {
this.cast(this.model);
this._castError = null;
} catch (err) {
this._castError = err;
}
// if we don't have a callback, then just return the query object
if (!callback) {
return Query.base.find.call(this);
}
this._find(callback);
return this;
};
I really don't understand the part
this._find(callback);
what this means? what is the _find in javascript?
Thanks in advance!
Max
what “this._find(callback)” means in Mongoose find() method?
It's a function call. It seems this._find
is a supposed to be a function. That function is called and passed the value of callback
.
what is the _find in javascript?
Nothing special. It's simply a property with name _find
. If you continue looking through the source code, you might discover its definition somewhere.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.