Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/facebook/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mongoose “接收”;类型错误:对象#<;事件发射器>;没有方法';更新字段'&引用;在后救球钩中_Mongoose - Fatal编程技术网

Mongoose “接收”;类型错误:对象#<;事件发射器>;没有方法';更新字段'&引用;在后救球钩中

Mongoose “接收”;类型错误:对象#<;事件发射器>;没有方法';更新字段'&引用;在后救球钩中,mongoose,Mongoose,这是代码的相关部分,我认为我在其中得到了错误,它说 “如果(this.ended&!this.hasRejectListeners())抛出原因 TypeError:对象#没有方法“updateMyField” 我很困惑为什么它声称没有任何方法-我会喜欢任何你能给予的帮助 问题在于post钩子要求您使用文档访问对象,如中所述 FieldSchema .post('save', function () { var self = this; self.updateMyField(

这是代码的相关部分,我认为我在其中得到了错误,它说

“如果(this.ended&!this.hasRejectListeners())抛出原因

TypeError:对象#没有方法“updateMyField”


我很困惑为什么它声称没有任何方法-我会喜欢任何你能给予的帮助

问题在于post钩子要求您使用文档访问对象,如中所述

FieldSchema
  .post('save', function () {
    var self = this;
    self.updateMyField();
  });

FieldSchema.methods = {  
  updateMyField: function() {
    var deferred = Q.defer();
    // Do things here
    return deferred.promise;
  }
};