instance of mongoose.model does not have a find method

I am a newbie with all of nodes and related stuff, one thing i cannot understand is why when creating a new object of a defined mongoose.model, there is no find or methods available in this new object, where as simply assigning a reference to a variable , gives me access to all methods ie

var obj = new mongoose.model('CollectionA' ,{}) here obj has access to only save and update methods and nothing else but doing var obj = mongoose.model('CollectionA' ,{}) gives obj access to all methods like find etc...

why is this happening ?


if you invoke

var myElementsCollection = mongoose.model('myElementsCollection' ,{}) 

it gives you access to Model(collection). So you will be able to use find, findAll etc

if you invoke with new

var myElements = new mongoose.model('myElementsCollection' ,{} )

you will create specific item that goes into this collection

链接地址: http://www.djcxy.com/p/89562.html

上一篇: Mongoose字符串到ObjectID

下一篇: mongoose.model的实例没有find方法