-
Type: New Feature
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: Operations Layer
Use Case
As a driver engineer I want to reduce the difference between node and common driver's spec. Currently our findOneAnd* methods only return a wrapped type for the findOneAnd* functions.
findOneAnd* methods should support an additional option of returnRawResult: [true|false] allowing the ModifyResult or the modified document to be returned instead.
User Impact
- Introduces a new option to return the spec compliant version of findAndModify*
- Default behavior will be left unchanged in v5 and will be flipped in v6 (see
NODE-3568)
Dependencies
- None
Unknowns
- None
Acceptance Criteria
Implementation Requirements
- Undeprecate ModifyResult
- Add an option to toggle returning the raw result from server in all findOneAnd* APIs (`returnRawResult`)
- Ensure null is returned if no results are found
- Add API and official guide documentation to what the option does
Dev note: returnRawResult is not meant to be prescriptive - the server returns a write_ops::FindAndModifyCommandReply, internally the driver returns a ModifyResult but our flag should make it clearer as to what is being returned.
Testing Requirements
- Add unit tests for the default and explicit true/false behavior of the new option
- Add typescript tests for the default and explicit true/false behavior of the new option
Documentation Requirements
- DOCSP ticket to add the new option to official docs
- API docs should clearly explain the option
Follow Up Requirements
- Give mongoose a heads up to explicitly set the option to preempt breaking changes ahead of V6
- If we use a different option name, update
NODE-3568