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.
Can someone fix?
If you don't feel like iterating, try FBFriendModel.find({ id:333 }).remove( callback );
or FBFriendModel.find({ id:333 }).remove().exec();
mongoose.model.find
returns a Query, which has a remove
function.
Update for Mongoose v5.5.3 - remove()
is now deprecated. Use deleteOne()
, deleteMany()
or findOneAndDelete() instead.