Mongo aggregate query results in less document with sorting
问题 I have faced a weird issue while querying one of our collections and aggregating the result out to another collection. I am querying unique users who have done some action and projecting the count of action performed per user in the aggregation query. var result = db.getCollection('user_actions').aggregate( [ {"$match":{"createdAt":{"$gte":1585161000000,"$lt":1585247340000}}}, {"$group":{"_id":{"accountId":"$user.id"},"count":{"$sum":1}}}, {"$sort": {"count": -1}}, {"$project":{"_id":0,"count