I am trying to execute my own MongoDB find
query using the collection
property of a Mongoose Model
object. I do not provide a callback, so I expect find to return a Cursor
object, but instead return undefined
. According to Mongoose docs , the driver used is available through YourModel.collection
, and if I switch to the purely find
driver code myself, return a Cursor
, so I cannot figure out what is happening.
Here is a piece of code that reproduces the problem:
var db = mongoose.connect('localhost', 'test'); var userSchema = new Schema({ username: String, emailAddress: String }); var User = mongoose.model('user', userSchema); var cursor = User.collection.find({});
I tried to enter the code using the node-inspector, but this does not allow me. Any idea what I'm doing wrong?
source share