我遇到了一个问题,想要从我的mongodb数据库中减go 2个字段,然后以变量的形式返回它们.
我正在使用bson.我将在golang 进行手术,但没有成功.
col2 := db.Collection("products")
pipe2 := []bson.M{
{"$group": bson.M{
"_id": IDUser,
"total": bson.M{"$subtract": {"$actualPrice", "$oldPrice"}},
}},
}
cur2, err := col2.Aggregate(ctx, pipe2)