“this._find(回调)”在猫鼬find()方法中是什么意思

what "this._find(callback)" means in Mongoose find() method?

本文关键字:find 方法 意思 是什么 this 回调      更新时间:2023-09-26

当我查看猫鼬.js的find()的源代码时,如下所示:

    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;
};

我真的不明白这部分

this._find(回调);

这意味着什么?JavaScript 中的_find是什么?

提前感谢!

麦克斯

猫鼬 find() 方法中的"this._find(回调)"是什么意思?

这是一个函数调用。似乎this._find应该是一个函数。调用该函数并传递 callback 的值。

JavaScript 中的_find是什么?

没什么特别的。它只是一个名称为 _find 的属性。如果您继续查看源代码,您可能会在某处发现它的定义。