【发布时间】:2023-03-06 12:28:02
【问题描述】:
我有这个查询:
produits = yield motor.Op(db.users.aggregate, [{"$unwind":"$pup"},{"$match":{"pup.spec.np":nomp}}, {"$group":{"_id":"$pup.spec.id","pup":{"$push":"$pup"}}}])
这给了我这个结果:
print produits
{u'ok': 1.0, u'result': [{u'_id': None, u'pup': [{u'avt': {u'fto': ..all the results}}]}]}
所以我可以这样做:
prod = produits["result"]
[{u'_id': None, u'pup': [{u'avt': {u'fto': ..all the results}}]}]
但是我怎样才能隐藏"_id",这样我只能得到:
[{u'pup': [{u'avt': {u'fto': ..all the results}}]}]
在普通查询中,我会简单地添加类似 {"_id":0} 的内容,但在这里它不起作用。
【问题讨论】:
标签: mongodb pymongo motordriver tornado-motor