LearnBoost/mongoose — Issue #630: Can't I use an object to query in mongoose?
Author: analysis918
Created: 2011-11-30 06:03:42+00:00
State: open

Hi,
i have a problem when i use an object as criteria when querying in mongoose.

var id = {
cid: 111,
vid: 222,
pid: 333
};

// the following doesn't work at all
Category.find({id: id}, function(err, docs) {
//----returns nothing.
});

// while
Category.find({'id.pid': id.pid, 'id.cid': id.cid,'id.vid': id.vid}, function(err, docs) {
//----returns some docs.
});
// does work`

Is this a problem or a feature?
Any help is appreciated.