这是收藏列表
{
_id : autoIncrement
"P_NAME" : "Name",
"P_LIST" : [
{
_id : autoIncrement
"P_TYPE" : "HELL",
"P_POOL" : "Not Use"
}
]
}
我在 MongoDB 中使用它时使用了这个命令。
db.P.find({},{"P_LIST": {$elemMatch: {_id:2}}, _id: 0})
同样在 Golang 中,我尝试搜索这样的条件,但没有成功。
collection.Find(context.TODO(), bson.M{bson.M{}, bson.M{"P_LIST":bson.M{"$elemMatch":bson.M{"_id":2}}, bson.M{"_id": 0}}})
Golang 如何将 Find 命令与 MongoDB 等条件和过滤器一起使用?
呼啦一阵风
相关分类