{ "_id" : ObjectId("61d6526cab5208fab93226a7"), "name" : "Albert Twostone", "age" : 68, "hobbies" : [ "sports", "cooking" ] }
{ "_id" : ObjectId("61d6526cab5208fab93226a8"), "name" : "Gordon Black", "age" : 38, "hobbies" : "sports" }
{ "_id" : ObjectId("61d652653b5208fab93226a8"), "name" : "Wayne Rooney", "age" : 28, "hobbies" : ["sports"] }
look 3 documents, and key hobbies.
my question is
- how can i get only Gordon Black??
- how can i get only Wayne Rooney or Albert Twostone??
i think 2. can be solved by using hobbies : {$size : 1} or hobbies : {$size : 2}
what about 1.???
find({hobbies : “sports”}) lead to 3 documents.
pleaase help me.