Setting up mongo client to decode document result into bson.M (instead of the default bson.D) for empty interface
34 views
Skip to first unread message
Vimal Patel
unread,
Jan 17, 2020, 2:40:45 PM1/17/20
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to mongodb-go-driver
I have a use case that requires me to decode document(s) result retrieved from calls to MongoDB via the Go Mongo driver into an empty/generic interface. The Mongo client by default returns the decoded result as a bson.D; however I need it to be returned as a bson.M so that I can output the decoded contents into our desired JSON structure. I have attempted various solutions including one provided in the comments forhttps://jira.mongodb.org/browse/GODRIVER-988that involves setting the Mongo client registry to return bson.M instead of bson.D without success. I have attached small go program with instructions included as commented out lines towards the top of the program for you to reproduce this issue. My guess is that I am not setting the registry for the mongo client correctly, hence I am not getting the desired result.