Skip to content

Commit a832898

Browse files
committed
make bulk write err constructor options required
1 parent 26b700b commit a832898

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

src/bulk/common.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -666,38 +666,38 @@ function handleMongoWriteConcernError(
666666
* @category Error
667667
*/
668668
export class MongoBulkWriteError extends MongoError {
669-
result?: BulkWriteResult;
669+
result: BulkWriteResult;
670670

671671
/** Number of documents inserted. */
672-
insertedCount?: number;
672+
insertedCount: number;
673673
/** Number of documents matched for update. */
674-
matchedCount?: number;
674+
matchedCount: number;
675675
/** Number of documents modified. */
676-
modifiedCount?: number;
676+
modifiedCount: number;
677677
/** Number of documents deleted. */
678-
deletedCount?: number;
678+
deletedCount: number;
679679
/** Number of documents upserted. */
680-
upsertedCount?: number;
680+
upsertedCount: number;
681681
/** Inserted document generated Id's, hash key is the index of the originating operation */
682-
insertedIds?: { [key: number]: ObjectId };
682+
insertedIds: { [key: number]: ObjectId };
683683
/** Upserted document generated Id's, hash key is the index of the originating operation */
684-
upsertedIds?: { [key: number]: ObjectId };
684+
upsertedIds: { [key: number]: ObjectId };
685685

686686
/** Creates a new MongoBulkWriteError */
687-
constructor(error?: AnyError, result?: BulkWriteResult) {
687+
constructor(error: AnyError, result: BulkWriteResult) {
688688
super(error as Error);
689689
Object.assign(this, error);
690690

691691
this.name = 'MongoBulkWriteError';
692692
this.result = result;
693693

694-
this.insertedCount = result?.insertedCount;
695-
this.matchedCount = result?.matchedCount;
696-
this.modifiedCount = result?.modifiedCount || 0;
697-
this.deletedCount = result?.deletedCount;
698-
this.upsertedCount = result?.upsertedCount;
699-
this.insertedIds = result?.insertedIds;
700-
this.upsertedIds = result?.upsertedIds;
694+
this.insertedCount = result.insertedCount;
695+
this.matchedCount = result.matchedCount;
696+
this.modifiedCount = result.modifiedCount;
697+
this.deletedCount = result.deletedCount;
698+
this.upsertedCount = result.upsertedCount;
699+
this.insertedIds = result.insertedIds;
700+
this.upsertedIds = result.upsertedIds;
701701
}
702702
}
703703

0 commit comments

Comments
 (0)