I have a mongoose schema as follows
var user_schema = new Schema({
reset : { type: Schema.Types.Mixed, required: true }
});
where reset is being given an object like this to store in the database
{
id: 23,
name: 'something'
}
I would like to look up a document based on the id in the reset object. This is what I have tried but I never get a result returned.
models.Users.findOne({ 'reset.id': id }, function (err, user) {
// user is null
});
Is a lookup like this possible with mongoose?
I think the issue you’re having is with using mixed schema type.
Could you not use an embedded doc of
ResetAnd then querying like: