Skip to content

Commit 6a8776c

Browse files
authored
feat(NODE-4681): deprecate modify result (#3459)
1 parent a143d3b commit 6a8776c

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

src/collection.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,12 @@ import {
9999
} from './utils';
100100
import { WriteConcern, WriteConcernOptions } from './write_concern';
101101

102-
/** @public */
102+
/**
103+
* @public
104+
* @deprecated This type will be completely removed in 5.0 and findOneAndUpdate,
105+
* findOneAndDelete, and findOneAndReplace will then return the
106+
* actual result document.
107+
*/
103108
export interface ModifyResult<TSchema = Document> {
104109
value: WithId<TSchema> | null;
105110
lastErrorObject?: Document;

test/types/community/collection/findX.test-d.ts

+18
Original file line numberDiff line numberDiff line change
@@ -348,3 +348,21 @@ expectType<WithId<{ a: number; b: string }> | null>(
348348
expectType<WithId<{ a: number; b: string }> | null>(
349349
(await coll.findOneAndDelete({ a: 3 }, { projection: { _id: 0 } })).value
350350
);
351+
352+
// NODE-3568: Uncomment when ModifyResult is removed in 5.0
353+
// expectType<WithId<TSchema> | null> | null>((await coll.findOneAndDelete({ a: 3 })));
354+
// expectType<WithId<TSchema> | null>(
355+
// (await coll.findOneAndReplace({ a: 3 }, { a: 5, b: 'new string' }))
356+
// );
357+
// expectType<WithId<TSchema> | null>(
358+
// (
359+
// await coll.findOneAndUpdate(
360+
// { a: 3 },
361+
// {
362+
// $set: {
363+
// a: 5
364+
// }
365+
// }
366+
// )
367+
// )
368+
// );

0 commit comments

Comments
 (0)