mongoose model find or code example
Example 1: callback mongoose get value from document
var query = Model.find({});
query.where('field', 5);
query.limit(5);
query.skip(100);
query.exec(function (err, docs) {
});
Example 2: == operation is not working on ids in express
Mongoose uses the mongodb-native driver, which uses the custom ObjectID type.
You can compare ObjectIDs with the .equals() method.
With your example, results.userId.equals(AnotherMongoDocument._id).
The ObjectID type also has a toString() method, if you wish to store a stringified version of the ObjectID in JSON
format, or a cookie.
If you use ObjectID = require("mongodb").ObjectID (requires the mongodb-native
library) you can check if results.userId is a valid identifier with
results.userId instanceof ObjectID.