我可以让Mongoose文档从实例方法中删除自己吗?

标题解释了这一切。 我有一个Mongoose文档,它有一个像这样的实例方法:

Model.methods.destroy = function(callback) { // blah blah this.remove(callback); } 

我怎么能告诉Model一个实例删除自己? 当我尝试this.remove ,它告诉我

 Uncaught TypeError: Object #<EventEmitter> has no method 'remove' 

this.constructor也没有remove

没关系。 可以办到。 我没有正确处理asynchronous性。 我之前在var self保存了一个这样的实例,我正在尝试this.remove而不是self.remove

Interesting Posts