-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(NODE-6329): client bulk write happy path
- Loading branch information
Showing
15 changed files
with
2,068 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { AbstractCursor } from './abstract_cursor'; | ||
|
||
export class ClientBulkWriteCursor extends AbstractCursor { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import { AbstractOperation } from '../operation'; | ||
|
||
export interface ClientBulkWriteResult { | ||
/** | ||
* The total number of documents inserted across all insert operations. | ||
*/ | ||
insertedCount: number; | ||
/** | ||
* The total number of documents upserted across all update operations. | ||
*/ | ||
upsertedCount: number; | ||
/** | ||
* The total number of documents matched across all update operations. | ||
*/ | ||
matchedCount: number; | ||
/** | ||
* The total number of documents modified across all update operations. | ||
*/ | ||
modifiedCount: number; | ||
/** | ||
* The total number of documents deleted across all delete operations. | ||
*/ | ||
deletedCount: number; | ||
} | ||
|
||
export interface VerboseClientBulkWriteResult extends ClientBulkWriteResult { | ||
/** | ||
* The results of each individual insert operation that was successfully performed. | ||
*/ | ||
insertResults: Map<number, ClientInsertOneResult>; | ||
/** | ||
* The results of each individual update operation that was successfully performed. | ||
*/ | ||
updateResults: Map<number, ClientUpdateResult>; | ||
/** | ||
* The results of each individual delete operation that was successfully performed. | ||
*/ | ||
deleteResults: Map<number, ClientDeleteResult>; | ||
} | ||
|
||
export interface ClientInsertOneResult { | ||
/** | ||
* The _id of the inserted document. | ||
*/ | ||
insertedId: any; | ||
} | ||
|
||
export interface ClientUpdateResult { | ||
/** | ||
* The number of documents that matched the filter. | ||
*/ | ||
matchedCount: number; | ||
|
||
/** | ||
* The number of documents that were modified. | ||
*/ | ||
modifiedCount: number; | ||
|
||
/** | ||
* The _id field of the upserted document if an upsert occurred. | ||
* | ||
* It MUST be possible to discern between a BSON Null upserted ID value and this field being | ||
* unset. If necessary, drivers MAY add a didUpsert boolean field to differentiate between | ||
* these two cases. | ||
*/ | ||
upsertedId?: any; | ||
} | ||
|
||
export interface ClientDeleteResult { | ||
/** | ||
* The number of documents that were deleted. | ||
*/ | ||
deletedCount: number; | ||
} | ||
|
||
export class ClientBulkWriteOperation extends AbstractOperation<ClientBulkWriteResult> { | ||
Check failure on line 76 in src/operations/client_bulk_write/client_bulk_write.ts GitHub Actions / build
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
218 changes: 218 additions & 0 deletions
218
test/spec/command-logging-and-monitoring/monitoring/unacknowledged-client-bulkWrite.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,218 @@ | ||
{ | ||
"description": "unacknowledged-client-bulkWrite", | ||
"schemaVersion": "1.7", | ||
"runOnRequirements": [ | ||
{ | ||
"minServerVersion": "8.0" | ||
} | ||
], | ||
"createEntities": [ | ||
{ | ||
"client": { | ||
"id": "client", | ||
"useMultipleMongoses": false, | ||
"observeEvents": [ | ||
"commandStartedEvent", | ||
"commandSucceededEvent", | ||
"commandFailedEvent" | ||
], | ||
"uriOptions": { | ||
"w": 0 | ||
} | ||
} | ||
}, | ||
{ | ||
"database": { | ||
"id": "database", | ||
"client": "client", | ||
"databaseName": "command-monitoring-tests" | ||
} | ||
}, | ||
{ | ||
"collection": { | ||
"id": "collection", | ||
"database": "database", | ||
"collectionName": "test" | ||
} | ||
} | ||
], | ||
"initialData": [ | ||
{ | ||
"collectionName": "test", | ||
"databaseName": "command-monitoring-tests", | ||
"documents": [ | ||
{ | ||
"_id": 1, | ||
"x": 11 | ||
}, | ||
{ | ||
"_id": 2, | ||
"x": 22 | ||
}, | ||
{ | ||
"_id": 3, | ||
"x": 33 | ||
} | ||
] | ||
} | ||
], | ||
"_yamlAnchors": { | ||
"namespace": "command-monitoring-tests.test" | ||
}, | ||
"tests": [ | ||
{ | ||
"description": "A successful mixed client bulkWrite", | ||
"operations": [ | ||
{ | ||
"object": "client", | ||
"name": "clientBulkWrite", | ||
"arguments": { | ||
"models": [ | ||
{ | ||
"insertOne": { | ||
"namespace": "command-monitoring-tests.test", | ||
"document": { | ||
"_id": 4, | ||
"x": 44 | ||
} | ||
} | ||
}, | ||
{ | ||
"updateOne": { | ||
"namespace": "command-monitoring-tests.test", | ||
"filter": { | ||
"_id": 3 | ||
}, | ||
"update": { | ||
"$set": { | ||
"x": 333 | ||
} | ||
} | ||
} | ||
} | ||
] | ||
}, | ||
"expectResult": { | ||
"insertedCount": { | ||
"$$unsetOrMatches": 0 | ||
}, | ||
"upsertedCount": { | ||
"$$unsetOrMatches": 0 | ||
}, | ||
"matchedCount": { | ||
"$$unsetOrMatches": 0 | ||
}, | ||
"modifiedCount": { | ||
"$$unsetOrMatches": 0 | ||
}, | ||
"deletedCount": { | ||
"$$unsetOrMatches": 0 | ||
}, | ||
"insertResults": { | ||
"$$unsetOrMatches": {} | ||
}, | ||
"updateResults": { | ||
"$$unsetOrMatches": {} | ||
}, | ||
"deleteResults": { | ||
"$$unsetOrMatches": {} | ||
} | ||
} | ||
}, | ||
{ | ||
"object": "collection", | ||
"name": "find", | ||
"arguments": { | ||
"filter": {} | ||
}, | ||
"expectResult": [ | ||
{ | ||
"_id": 1, | ||
"x": 11 | ||
}, | ||
{ | ||
"_id": 2, | ||
"x": 22 | ||
}, | ||
{ | ||
"_id": 3, | ||
"x": 333 | ||
}, | ||
{ | ||
"_id": 4, | ||
"x": 44 | ||
} | ||
] | ||
} | ||
], | ||
"expectEvents": [ | ||
{ | ||
"client": "client", | ||
"ignoreExtraEvents": true, | ||
"events": [ | ||
{ | ||
"commandStartedEvent": { | ||
"commandName": "bulkWrite", | ||
"databaseName": "admin", | ||
"command": { | ||
"bulkWrite": 1, | ||
"errorsOnly": true, | ||
"ordered": true, | ||
"ops": [ | ||
{ | ||
"insert": 0, | ||
"document": { | ||
"_id": 4, | ||
"x": 44 | ||
} | ||
}, | ||
{ | ||
"update": 0, | ||
"filter": { | ||
"_id": 3 | ||
}, | ||
"updateMods": { | ||
"$set": { | ||
"x": 333 | ||
} | ||
}, | ||
"multi": false | ||
} | ||
], | ||
"nsInfo": [ | ||
{ | ||
"ns": "command-monitoring-tests.test" | ||
} | ||
] | ||
} | ||
} | ||
}, | ||
{ | ||
"commandSucceededEvent": { | ||
"commandName": "bulkWrite", | ||
"reply": { | ||
"ok": 1, | ||
"nInserted": { | ||
"$$exists": false | ||
}, | ||
"nMatched": { | ||
"$$exists": false | ||
}, | ||
"nModified": { | ||
"$$exists": false | ||
}, | ||
"nUpserted": { | ||
"$$exists": false | ||
}, | ||
"nDeleted": { | ||
"$$exists": false | ||
} | ||
} | ||
} | ||
} | ||
] | ||
} | ||
] | ||
} | ||
] | ||
} |
Oops, something went wrong.