mgo db.collection.Remove() or RemoveAll() has problem with deleting from a list of values

632 views
Skip to first unread message

Saurabh Agarwal

unread,
Apr 12, 2017, 5:30:45 AM4/12/17
to mgo-users
I think we have run into an issue with mgo with mongo 3.4. A query which works from mongo shell is not working from Mongo golang Code.

This works and removes both the documents
>db.cpes.Remove({"cpeid":{"$in":["11111111111111111111111111111111","22222222222222222222222222222222"]}})

But this golang code doesn't work. It only deletes the document matching the first entry.
coll.Remove(bson.M{"cpeid": bson.M{"$in": []string{cpeids[0], cpeids[1]}}})

I know godoc says "Remove" will delete only one document but is there a way to remove multiple documents in one statement form golang code.

Any one has some idea?

Regards,
Saurabh

Jungyoon Lee

unread,
Apr 13, 2017, 2:15:00 AM4/13/17
to mgo-users
Have you considered using RemoveAll?
Reply all
Reply to author
Forward
0 new messages