mongodb - mongo query - return the values of field 1 where value of field 2 is x -
i want return name values document id = 10
below data:
{ "_id" : objectid("1"), "document id" : 10, "name" : "peter", date" : "01/1/2016" } { "_id" : objectid("2"), "document id" : 10, "name" : "mary", date" : "02/1/2016" } { "_id" : objectid("3"), "document id" : 10, "name" : "kate", date" : "03/1/2016" } { "_id" : objectid("3"), "document id" : 20, "name" : "bob", date" : "03/1/2016" } { "_id" : objectid("3"), "document id" : 20, "name" : "sam", date" : "03/1/2016" } { "_id" : objectid("3"), "document id" : 30, "name" : "jenny", date" : "03/1/2016" }
here query tried run:
db.collection.find({"document id":10},{"name"})
this error:
syntaxerror: unexpected token }
how can write query give me names id 10?
Comments
Post a Comment