I've this query:
produits = yield motor.Op(db.users.aggregate, [{"$unwind":"$pup"},{"$match":{"pup.spec.np":nomp}}, {"$group":{"_id":"$pup.spec.id","pup":{"$push":"$pup"}}}])
the result give me this:
print produits
{u'ok': 1.0, u'result': [{u'_id': None, u'pup': [{u'avt': {u'fto': ..all the results}}]}]}
so i can do:
prod = produits["result"]
[{u'_id': None, u'pup': [{u'avt': {u'fto': ..all the results}}]}]
but how do i hide "_id"
so i can only get
[{u'pup': [{u'avt': {u'fto': ..all the results}}]}]
in normal queries i just add something like {"_id":0}
here it dont work.
I'm not familiar with motor, but you ought to be able to delete the property from the results dict directly.
This is not exaclty a mongoWay of doing it, but you can use this factory to generate an object that includes all but _id
Then use it like this:
From mongodb docs
You can $project the results to exclude the
_id
- is this what you mean?http://docs.mongodb.org/manual/reference/aggregation/#pipeline
Note The _id field is always included by default. You may explicitly exclude _id as follows:
From you're example, the first operation in the pipeline would be to exclude the _id and include the other attribs.