Closed abdelouahabb closed 12 years ago
i don't know what you're trying to do, but you can't use position operator '$' in query, you can only use in update.
take a look here: http://stackoverflow.com/questions/6280259/mongodb-use-positional-operator-for-querying
the positional element here is used to return only the sub document (without using aggregate), so : db.users.find_one({"pup.spec.id":id}) will return the whole subdocument with its parent and other subdocuments. db.users.find_one({"pup.spec.id":id}, {"pup.spec.$.id":1}) will return only the subdocument. it works on pymongo.
i think it's the same as $elementmatch because it will not loop and returns the first element found?
okay, i'll try this...
there was a problem when you call without kwargs:
db.users.find_one({"pup.spec.id":id}, {"pup.spec.$.id":1})
to be work you needed to call with explicit fields: db.users.find_one({"pup.spec.id":id}, fields={"pup.spec.$.id":1})
i fixed this... now you can call without kwargs.
excellent ;) thank you a lot. catching now works also, thank you :) about gridfs i'm using filesystem + Ngnix ;)
how to make a positional element query:
this will show only the pup element and not the whole informations
db.users.find_one({"pup.spec.id":id}, {"pup.spec.$.id":1})