mongodb 时间范围查询

2018-12-21 00:00:00 < createtime < 2019-01-22 00:00:00

db.chat_intent.find({
	user:"cm93t1545274300cmt1ht5z",
	createtime:{"$gt":"2018-12-21 00:00:00","$lt":"2019-01-22 00:00:00"}
});

db.chat_intent.aggregate([
	{$match : {user:"cm93t1545274300cmt1ht5z",createtime:{"$gt":"2018-12-21 00:00:00","$lt":"2019-02-22 00:00:00"} }},
	{$group : {_id : "$intent" ,num: {$sum : 1}}},
	{$sort : {num:-1}},
]);

猜你喜欢

转载自blog.csdn.net/xiaojin21cen/article/details/87626698