Skip to content

Commit 41298c8

Browse files
authored
Docsp 30927 work with bson options (#278)
* DOCSP-30927-Work-With-BSON-Options * DOCSP-30927-Work-With-BSON-Options * DOCSP-30927-Work-With-BSON-Options * remove table * revision * revision
1 parent f7d1a93 commit 41298c8

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

source/fundamentals/bson.txt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,30 @@ Driver will marshal structs using the following rules:
210210
- Includes an empty ``lastname`` field
211211
- Stores the ``Address`` field as a nested value
212212

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+
213237
.. _golang-bson-unmarshalling:
214238

215239
Unmarshalling

0 commit comments

Comments
 (0)