Uploaded image for project: 'Go Driver'
  1. Go Driver
  2. GODRIVER-2765

Add an "omitzero" BSON struct tag

    • Type: Icon: New Feature New Feature
    • Resolution: Unresolved
    • Priority: Icon: Unknown Unknown
    • 2.1.0
    • Affects Version/s: None
    • Component/s: BSON
    • None
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?

      To support the use case of encoding Go structs as MongoDB documents, we will add an omitnil BSON struct tag that only omits nil values but includes empty values. The $push and $addToSet update operators work the same when modifying document fields that are empty arrays and document fields that do not exist (the only problem is document fields that are BSON null), so the behavior of omitnil maps well to that use case. Additionally, other MongoDB drivers (e.g. Java and Rust) offer a similar behaviors.

      Definition of done:

      • Add an omitnil BSON struct tag that only omits nil values but includes empty values.

            Assignee:
            Unassigned Unassigned
            Reporter:
            matt.dale@mongodb.com Matt Dale
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: