假设我有这个猫鼬查询:
const actors = await Actor.aggregate([{ "$group": {_id: "$loc.coordinates", count:{$sum:1}} }])
是否有一种方法可以只获得具有actors的count > 1?
actors
count > 1
发布于 2018-07-18 13:54:29
在$match后使用$group阶段
$match
$group
const actors = await Actor.aggregate([ { "$group": { "_id": "$loc.coordinates", "count": { "$sum": 1 }} }, { "$match": { "count": { "$gt": 1 }} } ])
https://stackoverflow.com/questions/51403007
相似问题