0
내가, 여기에 몇 가지 예를 들어 데이터입니다 파이썬에서 MongoDB를 수집에서 일부 데이터를 선택하기 위해 노력하고있어 :MongoDB를 집계 필터
[{"id":1, "planned_timestamp":1512728425, "executed_timestamp":0, "owner":1, "action_type": "read", "action_params":"book A"},
{"id":2, "planned_timestamp":1512728430, "executed_timestamp":0, "owner":1, "action_type": "read", "action_params":"book B"},
{"id":3, "planned_timestamp":1512728435, "executed_timestamp":0, "owner":2, "action_type": "read", "action_params":"book C"}]
내가 타임 스탬프 변수보다는 "executed_timestamp":0
, "planned_timestamp"
낮은 수있는 모든 작업을 선택합니다 pymongo와
[{"owner":1, "tasks": [{"id":1,"planned_timestamp":1512728425,"action_type": "read","action_params":"book A"},{"id":1,"planned_timestamp":1512728430,"action_type": "read","action_params":"book B"}]},
{"owner":2, "tasks": [{"id":3,"planned_timestamp":1512728435,"action_type": "read","action_params":"book C"}]}]
내 현재 요청은 다음과 같습니다 :
r = db.task_queue.aggregate(
[
{ "$group" : { "_id" : "$agent_id", "tasks": { "$push": "$$ROOT" } } }
]
)
나는 다음과 같은 결과를 가지고 싶습니다
agent_id는 소유자와 동일합니다. – BadTigrou
내 스크립트가 도움이 되었습니까? –