diff --git a/source/fundamentals/bson.txt b/source/fundamentals/bson.txt index a647334d..ca3c419f 100644 --- a/source/fundamentals/bson.txt +++ b/source/fundamentals/bson.txt @@ -210,6 +210,30 @@ Driver will marshal structs using the following rules: - Includes an empty ``lastname`` field - Stores the ``Address`` field as a nested value +BSON Options +------------ + +You can set ``BSONOptions`` to specify how +the driver marshals and unmarshals BSON on your collection, database, or +client. + +The following example demonstrates how to set ``BSONOptions`` for +the ``movies`` collection: + +.. code-block:: go + :copyable: false + + bsonOpts := &options.BSONOptions { + UseJSONStructTags: true, + } + coll := client.Database("sample_mflix") + .Collection("movies",bsonOpts) + +.. tip:: + + To learn more about ``BSONOptions``, see the `API Documentation + <{+api+}/mongo#example-Connect-BSONOptions>`__. + .. _golang-bson-unmarshalling: Unmarshalling