Skip to content

Commit 421a6b2

Browse files
assaf-xmmbroadst
authored andcommitted
feat(bulk): forward 'checkKeys' option for ordered and unordered bulk operations
* Forward checkKeys option for ordered and unordered bulks * checkKeys: fix tests
1 parent 45bc722 commit 421a6b2

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

lib/bulk/ordered.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,9 @@ function OrderedBulkOperation(topology, collection, options) {
303303
bypassDocumentValidation:
304304
typeof options.bypassDocumentValidation === 'boolean'
305305
? options.bypassDocumentValidation
306-
: false
306+
: false,
307+
// check keys
308+
checkKeys: typeof options.checkKeys === 'boolean' ? options.checkKeys : true
307309
};
308310
}
309311

@@ -513,6 +515,11 @@ var executeCommands = function(self, options, callback) {
513515
finalOptions.bypassDocumentValidation = true;
514516
}
515517

518+
// Is the checkKeys option disabled
519+
if (self.s.checkKeys === false) {
520+
finalOptions.checkKeys = false;
521+
}
522+
516523
try {
517524
if (batch.batchType === common.INSERT) {
518525
self.s.topology.insert(

lib/bulk/unordered.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,9 @@ var UnorderedBulkOperation = function(topology, collection, options) {
312312
bypassDocumentValidation:
313313
typeof options.bypassDocumentValidation === 'boolean'
314314
? options.bypassDocumentValidation
315-
: false
315+
: false,
316+
// check keys
317+
checkKeys: typeof options.checkKeys === 'boolean' ? options.checkKeys : true
316318
};
317319
};
318320

@@ -474,6 +476,11 @@ var executeBatch = function(self, batch, options, callback) {
474476
finalOptions.bypassDocumentValidation = true;
475477
}
476478

479+
// Is the checkKeys option disabled
480+
if (self.s.checkKeys === false) {
481+
finalOptions.checkKeys = false;
482+
}
483+
477484
try {
478485
if (batch.batchType === common.INSERT) {
479486
self.s.topology.insert(

0 commit comments

Comments
 (0)