#How to get _id as slice from returned cursor after find() function Golang & mongoDB
8 messages · Page 1 of 1 (latest)
That's not how append works
https://go.dev/tour/moretypes/15
i think problem is
append(roomIDs, bson.ObjectIdHex(restricstion["room_id"]))
bson.ObjectIdHex(restricstion["room_id"]) -> this method does'nt return type primitive.ObjectID. How can i get _id with type primitive.ObjectID from cursor 😦
bson.M is alias to map[string]interface{}
You need to cast it. i'll be trial and error it could be either string or already a primitive.ObjectID
restriction["room_id"].(primitive.ObjectID)
thank you
i tried with this but it's still not work 😢
Have you done the tour?
roomIDs = append(roomIDs, value)
thank you, it's my fault 😄
