@@ -74,8 +74,12 @@ use in the {+driver-short+}:
7474 - Description
7575
7676 * - ``omitempty``
77- - The field will not be marshalled if it is set to the zero value
78- corresponding to the field type.
77+ - The field will not be marshaled if it is set to the zero value
78+ corresponding to the field type. To globally prevent the driver from
79+ marshaling fields set to a zero value, you can set the ``OmitEmpty``
80+ BSON option. To learn more about how to set the ``OmitEmpty`` BSON option,
81+ see the example in the :ref:`BSON Options <golang-bson-options>`
82+ section of this page.
7983
8084 * - ``minsize``
8185 - If the field is type ``int64``, ``uint``, ``uint32``, or ``uint64`` and
@@ -211,6 +215,8 @@ the following rules:
211215 - Includes an empty ``lastname`` field
212216 - Stores the ``Address`` field as a nested value
213217
218+ .. _golang-bson-options:
219+
214220BSON Options
215221------------
216222
@@ -226,6 +232,8 @@ This example performs the following actions:
226232 to use the ``"json"`` struct tag if a ``"bson"`` struct tag is not specified
227233 - Sets the ``NilSliceAsEmpty`` field to ``true``, which instructs the driver
228234 to marshal ``nil`` Go slices as empty BSON arrays
235+ - Sets the ``OmitEmpty`` field to ``true``, which instructs the driver to globally omit
236+ empty values from the marshaled BSON, rather than set empty values to ``null``
229237
230238- Passes the ``BSONOptions`` instance to the ``SetBSONOptions()`` helper method to specify
231239 a ``ClientOptions`` instance
@@ -236,6 +244,7 @@ This example performs the following actions:
236244 bsonOpts := &options.BSONOptions {
237245 UseJSONStructTags: true,
238246 NilSliceAsEmpty: true,
247+ OmitEmpty: true,
239248 }
240249
241250 clientOpts := options.Client().
0 commit comments