我的 mongo 文件在这里
db.aaa.aggregate([{
$match : {
status : "Active"
}
}, {
$project : {
_id : 1,
title : 1,
postdatetime : 1,
status : 1,
answer : {
$filter : {
input : "$answer",
as : "answe",
cond : {
$eq : ["$$answe.status", "Active"]
}
}
}
}
}
])
我试试这个写进去
o2 := bson.M{
"$project":bson.M{
"$answer":bson.M{
"_id":1,"title":1,"postdatetime":1,"status":1,"answer":bson.M{
"$filter":bson.M{"input":"$answer","as":"ans","cond":bson.M{"$eq":bson.M["$$ans.status","Active",],},}
},
},
},
}
但它在 err语法错误中显示了这一点 :意外逗号,期待]
请帮帮我。
After the answer i try this one
o2: = bson.M {
"$project": bson.M {
"$answer": bson.M {
"_id": 1,
"title": 1,
"revision": 1,
"bgimageurl": 1,
"author": 1,
"postdatetime": 1,
"status": 1,
"qatags": 1,
"followers": 1,
"qaviews": 1,
"answer": bson.M {
"$filter": bson.M {
"input": "$answer",
"as": "ans",
"cond": bson.M {
"$eq": "[$$ans.status][,Active]",
},
},
},
},
},
}
这次编译成功,但是在运行 go 文件后,请向我发送这个 err msg 2016/05/11 11:04:17 $expressions are not allowed at the top-level of $project exit status 1
小怪兽爱吃肉
梦里花落0921
相关分类