Skip to content

Commit

Permalink
feat(NODE-4681): deprecate modify result (#3459)
Browse files Browse the repository at this point in the history
  • Loading branch information
durran committed Nov 8, 2022
1 parent a143d3b commit 6a8776c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/collection.ts
Expand Up @@ -99,7 +99,12 @@ import {
} from './utils';
import { WriteConcern, WriteConcernOptions } from './write_concern';

/** @public */
/**
* @public
* @deprecated This type will be completely removed in 5.0 and findOneAndUpdate,
* findOneAndDelete, and findOneAndReplace will then return the
* actual result document.
*/
export interface ModifyResult<TSchema = Document> {
value: WithId<TSchema> | null;
lastErrorObject?: Document;
Expand Down
18 changes: 18 additions & 0 deletions test/types/community/collection/findX.test-d.ts
Expand Up @@ -348,3 +348,21 @@ expectType<WithId<{ a: number; b: string }> | null>(
expectType<WithId<{ a: number; b: string }> | null>(
(await coll.findOneAndDelete({ a: 3 }, { projection: { _id: 0 } })).value
);

// NODE-3568: Uncomment when ModifyResult is removed in 5.0
// expectType<WithId<TSchema> | null> | null>((await coll.findOneAndDelete({ a: 3 })));
// expectType<WithId<TSchema> | null>(
// (await coll.findOneAndReplace({ a: 3 }, { a: 5, b: 'new string' }))
// );
// expectType<WithId<TSchema> | null>(
// (
// await coll.findOneAndUpdate(
// { a: 3 },
// {
// $set: {
// a: 5
// }
// }
// )
// )
// );

0 comments on commit 6a8776c

Please sign in to comment.