-
Type: New Feature
-
Resolution: Fixed
-
Priority: Unknown
-
Affects Version/s: None
-
Component/s: Operations Layer
-
Not Needed
-
Implement the client bulk write command builder.
AC:
- Command builder takes in an array of write models and returns an array of bulk write commands. For this first ticket it will always be one command.
- Implement the new model types:
- ClientInsertOneModel<TSchema>
- ClientUpdateOneModel<TSchema>
- ClientUpdateManyModel<TSchema>
- ClientReplaceOneModel<TSchema>
- ClientDeleteOneModel<TSchema>
- ClientDeleteManyModel<TSchema>
- Command must be in the format:
{ bulkWrite: 1, ops: DocumentSequence[], nsInfo: DocumentSequence[], errorsOnly: boolean, ordered: boolean, bypassDocumentValidation?: boolean, comment?: string, let?: Document }
- Operations must be in the format corresponding to the model and be embedded in an document sequence object with an "ops" key.
{ insert: number, // index of the namespace in nsInfo field. document: Document } { update: number, // index of the namespace in nsInfo field. filter: Document, updateMods: Document | Document[], multi?: boolean, upsert?: boolean, arrayFilters?: Document[], hint?: Document | string } { delete: number, // index of the namespace in nsInfo field. filter: Document, multi?: boolean, hint?: Document | string, collation?: Document }
- nsInfo must be a document sequence with an array of unique namespace objects in the format:
{ nsInfo: [{ ns: string }]}
Testing:
Add unit tests that pass a mixture of all available write models and assert that:
- Insert operations are in correct format
- Update operations are in correct format
- Delete operations are in correct format
- nsInfo array does not contain duplicate namespaces
- Indexes in the operations match the correct namespace