File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -210,6 +210,30 @@ Driver will marshal structs using the following rules:
210
210
- Includes an empty ``lastname`` field
211
211
- Stores the ``Address`` field as a nested value
212
212
213
+ BSON Options
214
+ ------------
215
+
216
+ You can set ``BSONOptions`` to specify how
217
+ the driver marshals and unmarshals BSON on your collection, database, or
218
+ client.
219
+
220
+ The following example demonstrates how to set ``BSONOptions`` for
221
+ the ``movies`` collection:
222
+
223
+ .. code-block:: go
224
+ :copyable: false
225
+
226
+ bsonOpts := &options.BSONOptions {
227
+ UseJSONStructTags: true,
228
+ }
229
+ coll := client.Database("sample_mflix")
230
+ .Collection("movies",bsonOpts)
231
+
232
+ .. tip::
233
+
234
+ To learn more about ``BSONOptions``, see the `API Documentation
235
+ <{+api+}/mongo#example-Connect-BSONOptions>`__.
236
+
213
237
.. _golang-bson-unmarshalling:
214
238
215
239
Unmarshalling
You can’t perform that action at this time.
0 commit comments