Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-4068

Return null when indicating absence of an object

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: None

      From the ECMAScript2015 spec

      4.3.10 undefined value
      primitive value used when a variable has not been assigned a value
      4.3.12 null value
      primitive value that represents the intentional absence of any object value

      AC

      • Audit usage of | undefined in return types, a function that "returns undefined" should actually be void.
      • If the API is supposed to return something or nothing it should always use null to indicate "nothing", ex. getWriteErrorAt
      • Investigate eslint rules to enforce this.

      Impact Considerations

      • null is serialized by JSON where undefined is not
      • undefined is (by default) ignored by our BSON library
      • undefined when deserialized from BSON is converted to null

            Assignee:
            Unassigned Unassigned
            Reporter:
            neal.beeken@mongodb.com Neal Beeken
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: