Useful Mongoose functions
suggest changefind, findOne, and findById are methods on a model. The name doc below has to be that model. They are not methods on a document you already loaded.
doc.find({'some.value':5},function(err,docs){
//returns array docs
});
doc.findOne({'some.value':5},function(err,doc){
//returns document doc
});
doc.findById(obj._id,function(err,doc){
//returns document doc
});
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents