-
Type: Improvement
-
Resolution: Unresolved
-
Priority: Minor - P4
-
None
-
Affects Version/s: None
-
Component/s: BSON
Use Case
As a JS engineer
I want to apply a BSON agnostic deep equality check to JS objects (documents)
So that I do not need special methods or handling to determine if two BSON instances are equal.
All BSON types should return true for util.isDeepStrictEqual if when serialized to BSON they result in the same byte sequence.
User Impact
- Should be none. Any changes needed should be internal.
Dependencies
- None
Unknowns
- BSON Binary tracks a position offset into a potentially much larger Uint8Array.
- If I have a Binary([0,0,0]) with position 1 and Binary([0]) with position 1, they aren't deep equal but they are BSON equal.
- Are there types other than binary that do not already satisfy this condition?
Investigation
- Determine changes needed to each BSON type to satisfy the equality requirement
Acceptance Criteria
Implementation Requirements
- Make changes to BSON types
Testing Requirements
- Generate BSON types that contain the same value but do not share any nested reference equality
- assert isDeepStrictEqual for each type
Documentation Requirements
- Add documentation (to BSONValue?) describing the equality guarantee
Follow Up Requirements
- NODE-1392 may be a nice-to-have along with this change
- related to
-
NODE-1392 Provide consistent `equals` API for all bson types
- Backlog