Skip to content

Commit

Permalink
feat(bulk): forward 'checkKeys' option for ordered and unordered bulk…
Browse files Browse the repository at this point in the history
… operations

* Forward checkKeys option for ordered and unordered bulks

* checkKeys: fix tests
  • Loading branch information
assaf-xm authored and mbroadst committed Jan 29, 2018
1 parent 45bc722 commit 421a6b2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
9 changes: 8 additions & 1 deletion lib/bulk/ordered.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,9 @@ function OrderedBulkOperation(topology, collection, options) {
bypassDocumentValidation:
typeof options.bypassDocumentValidation === 'boolean'
? options.bypassDocumentValidation
: false
: false,
// check keys
checkKeys: typeof options.checkKeys === 'boolean' ? options.checkKeys : true
};
}

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

// Is the checkKeys option disabled
if (self.s.checkKeys === false) {
finalOptions.checkKeys = false;
}

try {
if (batch.batchType === common.INSERT) {
self.s.topology.insert(
Expand Down
9 changes: 8 additions & 1 deletion lib/bulk/unordered.js
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,9 @@ var UnorderedBulkOperation = function(topology, collection, options) {
bypassDocumentValidation:
typeof options.bypassDocumentValidation === 'boolean'
? options.bypassDocumentValidation
: false
: false,
// check keys
checkKeys: typeof options.checkKeys === 'boolean' ? options.checkKeys : true
};
};

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

// Is the checkKeys option disabled
if (self.s.checkKeys === false) {
finalOptions.checkKeys = false;
}

try {
if (batch.batchType === common.INSERT) {
self.s.topology.insert(
Expand Down

0 comments on commit 421a6b2

Please sign in to comment.