Skip to content

Commit d006adc

Browse files
committed
feat(NODE-4034): make internal bulk result private
1 parent fe65746 commit d006adc

File tree

2 files changed

+5
-29
lines changed

2 files changed

+5
-29
lines changed

src/bulk/common.ts

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,7 @@ export type AnyBulkWriteOperation<TSchema extends Document = Document> =
123123
| { deleteOne: DeleteOneModel<TSchema> }
124124
| { deleteMany: DeleteManyModel<TSchema> };
125125

126-
/**
127-
* @public
128-
*
129-
* @deprecated Will be made internal in 5.0
130-
*/
126+
/** @internal */
131127
export interface BulkResult {
132128
ok: number;
133129
writeErrors: WriteError[];
@@ -172,15 +168,15 @@ export class Batch<T = Document> {
172168
* The result of a bulk write.
173169
*/
174170
export class BulkWriteResult {
175-
/** @deprecated Will be removed in 5.0 */
176-
result: BulkResult;
171+
private result: BulkResult;
177172

178173
/**
179174
* Create a new BulkWriteResult instance
180175
* @internal
181176
*/
182177
constructor(bulkResult: BulkResult) {
183178
this.result = bulkResult;
179+
Object.defineProperty(this, 'result', { value: this.result, enumerable: false });
184180
}
185181

186182
/** Number of documents inserted. */
@@ -314,13 +310,8 @@ export class BulkWriteResult {
314310
}
315311
}
316312

317-
/* @deprecated Will be removed in 5.0 release */
318-
toJSON(): BulkResult {
319-
return this.result;
320-
}
321-
322313
toString(): string {
323-
return `BulkWriteResult(${this.toJSON()})`;
314+
return `BulkWriteResult(${this.result})`;
324315
}
325316

326317
isOk(): boolean {

test/tools/unified-spec-runner/operations.ts

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -657,22 +657,7 @@ operations.set('rewrapManyDataKey', async ({ entities, operation }) => {
657657
const clientEncryption = entities.getEntity('clientEncryption', operation.object);
658658
const { filter, opts } = operation.arguments!;
659659

660-
const rewrapManyDataKeyResult = await clientEncryption.rewrapManyDataKey(filter, opts);
661-
662-
if (rewrapManyDataKeyResult.bulkWriteResult != null) {
663-
// TODO(NODE-4393): refactor BulkWriteResult to not have a 'result' property
664-
//
665-
// The unified spec runner match function will assert that documents have no extra
666-
// keys. For `rewrapManyDataKey` operations, our unifed tests will fail because
667-
// our BulkWriteResult class has an extra property - "result". We explicitly make it
668-
// non-enumerable for the purposes of testing so that the tests can pass.
669-
const { bulkWriteResult } = rewrapManyDataKeyResult;
670-
Object.defineProperty(bulkWriteResult, 'result', {
671-
value: bulkWriteResult.result,
672-
enumerable: false
673-
});
674-
}
675-
return rewrapManyDataKeyResult;
660+
return await clientEncryption.rewrapManyDataKey(filter, opts);
676661
});
677662

678663
operations.set('deleteKey', async ({ entities, operation }) => {

0 commit comments

Comments
 (0)