Please tell me what am I missing here:
this is the Doc I created:
fatDoc = {
name: "Babak",
personID : 555,
email : "babak@babak.name",
music : ["pink floyd", "muse", "garfunkel"],
food : ["free food", "yummy food", "mom food"],
addresses:
[ { type: "home",
street: "123 Main",
state: "NY",
city: "brooklyn"
},
{ type: "vacation",
street: "456 sunshine",
state: "CA",
city: "SanFran"
}
]
}
and this is the query I run on it:
db.coolkids.find({"addresses.type" : "home"}, {addresses:1}).pretty()
Question1: Why BOTH of addresses are getting returned as the result of this query? Question2: How can I change it to ONLY return the first doc which is the "home" address and not the second member of the array?