MongoDB retrieves data in scope, deletes data that are not eligible, aggregates the calculated mean

Time:2019-10-9

Find a time range of data

db['Copy(1)_of_20180401'].find({'t':{$gte:'2018-04-01 20:00:00'},'t':{$lte:'2018-04-01 21:00:00'}})

Delete after taking back

db['Copy(1)_of_20180401'].remove({'t':{$not:{$lte:'2018-04-01 22:00:00'}}})

Average value of aggregation calculation

db['Copy(1)_of_20180401'].aggregate({"$group":{_id: 'avg',avg_value:{"$avg":"$uf"}}});

This article is comprehensive: https://blog.csdn.net/zwq9123…