Mongodb: Trying to find all documents with specific subdocument field, why is my query not working? -


Here is an example of a document from the collection that I ask

  Meteor: primary & Gt; Db.research.findOne ({_ id: 'Z2zzA7dx6unkzKiSn'}) "": "Z2zzA7dx6unkzKiSn", "_userId": "NtE3ANq2b2PbWSEqu", "affiliate": [{"userId": "aTPzFad8DdFXxRrX4"}], "name "" new "," pending ": {" associate ": []}}  

I have all the documents within this collection either _userId: 'aTPzFad8DdFXxRrX4' or find partners I array, userId: 'aTPzFad8DdFXxRrX4'

that's why I want to see the collection go and if _userId field 'aTPzFad8DdFXxRrX4' If not then check the associate array on the document and check whether the user id: 'aTPzFad8DdFXxRrX4' Is an object with

Aँ I'm trying to use the query:

  db.research.find ({$ or: [[_userId: 'aTPzFad8DdFXxRrX4'}, {associate in the {$: [{ userId: 'the aTPzFad8DdFXxRrX4'}]}}}}}  

it does not have the document and gives me a syntax error my problem here? Thank you

The operator is basically a simplified version, but in reality you only have one argument so that you do not even need it Is it instead Use the notation:

  db.research.find ({ '$ or': {{_ _ _ _ _ '': 'aTPzFad8DdFXxRrX4' }, {'If you need more than one value, then use  $ in : 

Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -