1

all the documentation on this subject seems aimed at retrieving elements from an array stored in mongodb. I have a document:

{
   "user1": { ... },
   "user2": { ... },
   ...
}

and want to retrieve the object stored for user1 but cannot find a way to formulate the query:

collection.find({user1})

won't work because it's destructuring of a variable that doesn't exist

var q = {}; q.user1 = '';
collection.find(q)

also wouldn't work because it would be looking for '' as the value.

how is this done??

and no, please don't post that I need to restructure my data as an array or in some other way. if it can't be done, just say so. thanks!

ekkis
  • 9,804
  • 13
  • 55
  • 105

0 Answers0