Reputation: 317
Let's say I have a schema as
var TempSchema = new Schema({
location: Schema.Types.Mixed
});
location will store a json object
now I want to search by a property inside this json object field, can I use following query ?
Temp.find({location.country: {$in: ['US', 'CN', 'JP']}});
Upvotes: 7
Views: 6262
Reputation: 14562
Yes you can do it using the dot notation, just enclose it inside quotes:
Temp.find({"location.country": {$in: ['US', 'CN', 'JP']}}, function(err, data) { /* ... */});
Upvotes: 8