-
Type: Task
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: TypeScript
Use Case
As a... user of the Node.js driver
I want... to be able to use my collection's read schema directly to type the returned documents of read and write operations such as findAndModify
So that... I don't have to use awkward wrappers or rely strictly on the driver's type inference to get the correct type results
User Impact
- Ensures user defined types work as expected
Dependencies
- None
Unknowns
- Complete list of operations that returns a full document
Acceptance Criteria
- Add TS tests to make sure that the returned document in the result of each operation applied to a `Collection<OptionalId<SchemaWithId>>` is assignable to `SchemaWithId` (where `SchemaWithId` is a collection schema that has `_id: ObjectId`)
- Enumerate any methods which currently do not support this
- Try to see if there is a straightforward adjustment that can be made to our OptionalId or read operation result types to enable this use case
- If not, discuss next steps with team, so that we can decide how we want to proceed for V5
Implementation Requirements
- see AC
Testing Requirements
- TS tests
Documentation Requirements
- N/A
Follow Up Requirements
- If the issue cannot be addressed, we'll need a follow up ticket, possibly design, for handling schemas in V5