How can I query with elemMatch in mongoose?
Documentation for elemMatch in mongoose is here.
I've not tested it, but it looks like you'll want to do
User.find().elemMatch("boxes", {"a":"foo","b":"bar"})
Tim's answer is correct, but if anyone runs into confusion with what mongoose generates for queries on the mongo native API, I used this to figure that out
mongoose.set('debug', function (coll, method, query, doc) {
console.log(coll + " " + method + " " + JSON.stringify(query) + " " + JSON.stringify(doc));
});