1 、 与下列 SQL 语句等价的 MongoDB 命令是什么?(B)
SELECT author, count(*) FROM posts GROUP BY author HAVING count(*) > 1
A.
db.posts.aggregate( [
{
$group: {
_id: "$author",
count: { $sum : 1 },
$match: { count: { $gt: 1 } }
}
}
] )
B.
db.posts.aggregate( [
{
$group: {
_id: "$author",
count: { $sum : 1 }
}
},
{ $match: { count: { $gt: 1 } } }
] )
C.
db.posts.aggregate( [
{ $match: { count: { $gt: 1 } } },
{
$group: {
_id: "$author",
count: { $sum : 1 }
}