我有包含以下模式文档的集合。我想过滤/查找包含女性性别的所有文档并汇总总分。我尝试了以下语句,它显示了无效的管道错误。
db['!all'].aggregate({ $and: [ {'GENDER' : 'F'} , {'DOB' : { $gte : 19400801, $lte : 20131231 }} ] }, { $group : { _id : "$GENDER", totalscore : { $sum : "$BRAINSCORE" } } } )
架构:
{
"_id" : ObjectId("53f63fc8f2b643f6ebb8a1a9"),
"DOB" : 19690112,
"GENDER" : "F",
"BRAINSCORE" : 65
},
{
"_id" : ObjectId("53f63fc8f2b643f6ebb8a1a2"),
"DOB" : 19950116,
"GENDER" : "F",
"BRAINSCORE" : 44
},
{
"_id" : ObjectId("53f63fc8f2b643f6ebb8a902"),
"DOB" : 19430216,
"GENDER" : "M",
"BRAINSCORE" : 71
}
请帮忙...