Hello, in my collection there are records like this:

{ "_id" : ObjectId("585a6bd6e4b06b1f23195304"), "name" : "somename", "members" : { "somemembername1" : { "rank" : 3 }, "somemembername2" : { "rank" : 2 }, "somemembername3" : { "rank" : 1 } } } 

I need to make a request in the database so that it returns an entry to the members of which there is a certain somemembername. Ie, I will look for an entry in the collection by the single value of somemembername. The same value of somemember in the records is never repeated.

    1 answer 1

    If I understand you correctly:

     var search = "members." + somemembername; db.namecollection.findOne({search:{$exists:true}});