From 41298c81c5e02ff3c89b6e1c1c66f1c94a22ad1e Mon Sep 17 00:00:00 2001 From: nickldp <135850974+nickldp@users.noreply.github.com> Date: Tue, 11 Jul 2023 14:32:38 -0400 Subject: [PATCH] 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 --- source/fundamentals/bson.txt | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) 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