How to hide _id from Aggregation?

后端 未结 4 1149
广开言路
广开言路 2020-12-30 21:25

I\'ve this query:

produits = yield motor.Op(db.users.aggregate, [{\"$unwind\":\"$pup\"},{\"$match\":{\"pup.spec.np\":nomp}}, {\"$group\":{\"_id\":\"$pup.spec         


        
4条回答
  •  北荒
    北荒 (楼主)
    2020-12-30 22:03

    I'm not familiar with motor, but you ought to be able to delete the property from the results dict directly.

    >>> produits = {u'ok': 1.0, u'result': [{u'_id': None, u'pup': [{u'avt': {u'fto': 'whatever'}}]}]}
    >>> prod = produits['result'] 
    >>> del prod[0]['_id']
    >>> print prod
    [{u'pup': [{u'avt': {u'fto': 'whatever'}}]}]
    

提交回复
热议问题