go - Querying mongodb from golang using the _id stored in an array -
So here's my question I have an array that stores the _id
of mongodbs objects What is the correct way to retrieve all these in a query using the MGO and BSN package?
So if the array is such: id: = ["543d171c5b2c12420dd016", "543d171c5b2dd016"]
How do we query? I tried to do this but I have a wrong address.
query: = bson.m {"_ id": bson.m {"$ in": ids}} c.Find (query) All ()
Thanks in advance
If the documents are stored With string id, the code looks correct.
ID hex looks like encoded object ID if object identifiers are object IDs, then you need to convert hex strings to object ID: i i = class IDs {AIDS [i] = BSN . Object IDHX (ID [I])} query: = BSONM. {"_ ID": BSONM M {"$ in": ODS}}
Comments
Post a Comment