2 回答

TA貢獻(xiàn)1864條經(jīng)驗(yàn) 獲得超6個(gè)贊
錯(cuò)誤來自您初始化arrayin的方式go:
....
"$and": []interface{}{
"shr_key": user_shr_key,
....
go數(shù)組不接受string作為索引。
無論如何,為了解決您的問題,從數(shù)組初始化中刪除索引并將鍵值對包裝進(jìn)去bson.M就可以了,例如:
bson.M{
"$and": []bson.M{ // you can try this in []interface
bson.M{"shr_key": user_shr_key},
bson.M{"id": uid},
bson.M{"user_history": bson.M{"$elemMatch": bson.M{"action": "STOP", "message_id": mid}}},
},
}

TA貢獻(xiàn)1850條經(jīng)驗(yàn) 獲得超11個(gè)贊
在這里你可以看到,通過 $Match 獲取值,$and 使用 Golang MongoDB
pipeline := []bson.M{
bson.M{"$match": bson.M{"$and": []bson.M{bson.M{"storyID": storyID},
bson.M{"parentID": parentID}}}}
}
- 2 回答
- 0 關(guān)注
- 215 瀏覽
添加回答
舉報(bào)