https://godoc.org/github.com/mongodb/mongo-go-driver
我正在尝试动态创建聚合管道。例如,我想读取一段包含海洋的字符串。我试着把它们拆成碎片,但我找不到任何方法来追加元素。
pipeline := bson.NewArray(
bson.VC.DocumentFromElements(
bson.EC.SubDocumentFromElements(
"$match",
bson.EC.SubDocumentFromElements("ocean",
bson.EC.ArrayFromElements("$in",
bson.VC.String("Pacific Ocean"),
//bson.VC.String("Indian Ocean"),
),
),
bson.EC.SubDocumentFromElements("callTypeName",
bson.EC.ArrayFromElements("$in",
bson.VC.String("Wookie"),
bson.VC.String("Unknown 13"),
),
),
),
),
)
cur, err := collection.Aggregate(context.Background(), pipeline)
偶然的你
相关分类