How do I remove documents using Node.js Mongoose?
FBFriendModel.find({
id: 333
}, function (err, docs) {
docs.remove(); //Remove all the documents that match!
});
The above doesn't seem to work. The records are still there.
How mongoose delete the document?
To remove documents using Node.js Mongoose without iterating, you can try
FBFriendModel.find({ id:333 }).remove( callback );
Or
FBFriendModel.find({ id:333 }).remove().exec();
The mongoose.model.find method returns a Query, which has a remove function.
This will work for mongoose delete document.