0

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!

Nilay Parikh
  • 328
  • 3
  • 14
  • possible duplicate of [Find document with array that contains a specific value](http://stackoverflow.com/questions/18148166/find-document-with-array-that-contains-a-specific-value) – Yves M. Jan 27 '14 at 17:10

1 Answers1

7
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".

Peter Lyons
  • 142,938
  • 30
  • 279
  • 274