EJSON.stringify() replacer array should add data types

XMLWordPrintableJSON

    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Use Case

      As a developer
      I want to add a replacer array to EJSON.stringify without adding $oid, etc
      So that I can get a stringified EJSON without worrying about the data types being removed

      User Experience

      const testDoc = {
        objectId: ObjectId.createFromHexString('111111111111111111111111')
      };
      
      const result = EJSON.stringify(testDoc, ['objectId', '$oid']) // {"objectId":{"$oid":"111111111111111111111111"}}
      const result2 = EJSON.stringify(testDoc, ['objectId']) // {"objectId":{}} -> expected: same as result
      

       

      Dependencies

      None

      Risks/Unknowns

      • What could go wrong while implementing this change? (e.g., performance, inadvertent behavioral changes in adjacent functionality, existing tech debt, etc)
        It modifies the current behaviour of a replacer array. Therefore alters how it works.
        I would reason that it is the more expected result.
      • Is there an opportunity for better cross-driver alignment or testing in this area?
        I do not know
      • Is there an opportunity to improve existing documentation on this subject?
        An alternative to modifying how the replacer works is to document that the data type keys need to be added to an replacer array.

      Acceptance Criteria

      Implementation Requirements

      • functional reqs, potential snafus to avoid, performance targets, etc
        const testDoc = {
          objectId: ObjectId.createFromHexString('111111111111111111111111')
        };
        
        const result = EJSON.stringify(testDoc, ['objectId', '$oid'])
        const result2 = EJSON.stringify(testDoc, ['objectId'])
        // expect result === result2
        

      Testing Requirements

      • unit test, spec test sync, etc
        some tests to make sure every data type key is included

      Documentation Requirements

      • DOCSP ticket, API docs, etc
        Release Notes

            Assignee:
            Unassigned
            Reporter:
            Daniel Müller
            None
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: