All my life had beeb Oracle Development, just right now I’m starting witn mongoDB, and I need help with this query 'cause don’t work as I wish, it retrive all rows and not a specific row.
> db.layouts.find({}, {_id: 1})
{ "_id" : "adresses" }
{ "_id" : "clients" }
> db.layouts.find({_id: "clients"}, {"info.id": 1, "info.married": 1, _id: 0})
{ "info" : [ { "id" : "luis.alvarez", "married" : 1 }, { "id" : "jose.perez", "married" : 0 }, { "id" : "daniel.contreras", "married" : 0 }, { "id" : "javier.pirela", "married" : 0 } ] }
> db.layouts.find({_id: "clients", "info.married": "1"}, {"info.id": 1, "info.married": 1, _id: 0})
> db.layouts.find({_id: "clients", "info.married": 1}, {"info.id": 1, "info.married": 1, _id: 0})
{ "info" : [ { "id" : "luis.alvarez", "married" : 1 }, { "id" : "jose.perez", "married" : 0 }, { "id" : "daniel.contreras", "married" : 0 }, { "id" : "javier.pirela", "married" : 0 } ] }
> db.layouts.find({_id: "clients", "info.id": "luis.alvarez"}, {"info.id": 1, "info.married": 1, _id: 0})
> db.layouts.find({_id: "clients", "info.married": 1}, {"info.id": 1, "info.married": 1, _id: 0})
{ "info" : [ { "id" : "luis.alvarez", "married" : 1 }, { "id" : "jose.perez", "married" : 0 }, { "id" : "daniel.contreras", "married" : 0 }, { "id" : "javier.pirela", "married" : 0 } ] }
As you can see, for the document clients (_id=clients) and married marital status (married=1)retrieves all clients regardless of status, why is this?
Thanks in advance by your help !!!