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

Popular posts from this blog

java - Spring Data JPA: Why findOne(id) executing delete query internally? -

python - Mongodb How to add addtional information when aggregating? -

java - Incorrect order of records in M-M relationship in hibernate -