Model.find({TaxonomyIDs: 1}, function(error, models) {
//put code to process the results here
});
mongodb interprets the query conditions above as "match any document where the TaxonomyIDs array contains 1".
Question
I'm trying to query into following document and want to list all document which contains TaxonomyID "1" in "TaxonomyIDs" field.
...
"Slug" : "videosecu-600tvl-outdoor-security-surveillance",
"Category" : "Digital Cameras",
"SubCategory" : "Surveillance Cameras",
"Segment" : "",
"Usabilities" : [
"Dome Cameras",
"Night Vision"
],
"TaxonomyIDs" : [
1,
12,
20,
21,
13
],
"Brand" : "VideoSecu",
...
Totally stuck!
Solution
Model.find({TaxonomyIDs: 1}, function(error, models) {
//put code to process the results here
});
mongodb interprets the query conditions above as "match any document where the TaxonomyIDs array contains 1".