Skip to content

Commit 5427509

Browse files
committed
undo changes to bulk
1 parent a9d4de5 commit 5427509

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

src/collection.ts

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ export class Collection implements OperationParent {
368368
callback?: Callback<BulkWriteResult>
369369
): Promise<BulkWriteResult> | void {
370370
if (typeof options === 'function') (callback = options), (options = {});
371-
options = resolveInheritedOptions(this, options ?? { ordered: true });
371+
options = options || { ordered: true };
372372

373373
if (!Array.isArray(operations)) {
374374
throw new MongoError('operations must be an array of documents');
@@ -1305,14 +1305,24 @@ export class Collection implements OperationParent {
13051305

13061306
/** Initiate an Out of order batch write operation. All operations will be buffered into insert/update/remove commands executed out of order. */
13071307
initializeUnorderedBulkOp(options?: BulkWriteOptions): any {
1308-
options = resolveInheritedOptions(this, options);
1309-
return new UnorderedBulkOperation(this, options);
1308+
options = options || {};
1309+
// Give function's options precedence over session options.
1310+
if (options.ignoreUndefined == null) {
1311+
options.ignoreUndefined = this.bsonOptions.ignoreUndefined;
1312+
}
1313+
1314+
return new UnorderedBulkOperation(this, options ?? {});
13101315
}
13111316

13121317
/** Initiate an In order bulk write operation. Operations will be serially executed in the order they are added, creating a new operation for each switch in types. */
13131318
initializeOrderedBulkOp(options?: BulkWriteOptions): any {
1314-
options = resolveInheritedOptions(this, options);
1315-
return new OrderedBulkOperation(this, options);
1319+
options = options || {};
1320+
// Give function's options precedence over session options.
1321+
if (options.ignoreUndefined == null) {
1322+
options.ignoreUndefined = this.bsonOptions.ignoreUndefined;
1323+
}
1324+
1325+
return new OrderedBulkOperation(this, options ?? {});
13161326
}
13171327

13181328
/** Get the db scoped logger */

0 commit comments

Comments
 (0)