node.js - Can I have a Mongoose document delete itself from an instance method? -
title explains all. have mongoose document has instance method this:
model.methods.destroy = function(callback) { // blah blah this.remove(callback); } how can tell instance of model delete itself? when try this.remove, tells me
uncaught typeerror: object #<eventemitter> has no method 'remove' and this.constructor not have remove either.
never mind. can done. wasn't handling asynchronicity properly. saved instance of this in var self earlier , trying this.remove instead of self.remove.
Comments
Post a Comment