我有這樣一個集合:如何使用mongodb聚合?
{'speed':45, 'time':1446271000},
{'speed':45, 'time':1446271001},
{'speed':63, 'time':1446271002},
{'speed':68, 'time':1446271003},
{'speed':70, 'time':1446271004},
{'speed':59, 'time':1446271005},
{'speed':55, 'time':1446271006},
{'speed':61, 'time':1446271007},
{'speed':62, 'time':1446271008},
{'speed':63, 'time':1446271009},
{'speed':67, 'time':1446271010}
我想總結高速(速度> = 60)的記錄,因此結果應該是這樣的:
{'speed':63,'duration':2,'start': 1446271002,'end': 1446271004}
{'speed':61,'duration':3,'start': 1446271007,'end': 1446271010}
我應該如何做到這一點?
你想要的結果由起始時間進行排序? – jpaljasma