$comment
最后更新于
最后更新于
db.records.find(
{
x: { $mod: [ 2, 0 ] },
$comment: "Find even values."
}
)db.records.aggregate( [
{ $match: { x: { $gt: 0 }, $comment: "Don't allow negative inputs." } },
{ $group : { _id: { $mod: [ "$x", 2 ] }, total: { $sum: "$x" } } }
] )