$pull doesn't work

19 views
Skip to first unread message

周小帅

unread,
Dec 20, 2019, 11:20:18 AM12/20/19
to mongodb-go-driver
_, err := db.Collection(conf.Sku).UpdateOne(context.TODO(), bson.M{
"client_id": x.ClientId, "bid": x.BID, "_id": x.ID,
}, bson.M{"$pull": bson.D{{"tags", x.ID}}})

"tags" is a array that contain some ids.
result: the err is nil,but the program didn't do any thing!!Is the err in the $pull?

Divjot Arora

unread,
Jan 2, 2020, 10:39:57 AM1/2/20
to mongodb-go-driver
Hi,

Can you capture the result return from the UpdateOne function() (e.g. res, err := db.Collection().UpdateOne()) and take a look at the contents? It will give information like the number of documents matched by the filter and the number of documents actually updated.  
Reply all
Reply to author
Forward
0 new messages