[GODRIVER-1416] Add function to marshal generic BSON values Created: 21/Nov/19  Updated: 28/Oct/23  Resolved: 05/Dec/19

Status: Closed
Project: Go Driver
Component/s: BSON
Affects Version/s: None
Fix Version/s: 1.2.0

Type: New Feature Priority: Major - P3
Reporter: Divjot Arora (Inactive) Assignee: Divjot Arora (Inactive)
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

Our BSON library has bson.Marshal which will take interface{} and create a BSON document. We do not have a function like bson.MarshalValue to take interface{} and create an arbitrary BSON value (not necessarily a document). This is something that could be useful as part of an implementation for MarshalBSONValue for a struct type. See GODRIVER-1340 for a use case.

I wrote up a code sample to show a use of this and how it's handled now: https://gist.github.com/divjotarora/5bc3b6f85ef1030df6db83648c91dea6

CC craiggwilson may.hoque Craig mentioned that this could be useful for Data Lake (something about marshalling aggregation pipelines, which are arrays). Can you elaborate on the use case?



 Comments   
Comment by Githook User [ 05/Dec/19 ]

Author:

{'name': 'Divjot Arora', 'username': 'divjotarora', 'email': 'divjot.arora@10gen.com'}

Message: GODRIVER-1416 Add bson.MarshalValue (#241)
Branch: master
https://github.com/mongodb/mongo-go-driver/commit/3d3d8959e87de9f6e9ba8562ad9a005c664f3af0

Comment by Divjot Arora (Inactive) [ 03/Dec/19 ]

CR: https://github.com/mongodb/mongo-go-driver/pull/241

Generated at Thu Feb 08 08:36:21 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.