From 3cf502a2360ebd61e757949fa7c3a4f59a811ae4 Mon Sep 17 00:00:00 2001 From: Durran Jordan Date: Wed, 2 Nov 2022 15:27:30 +0100 Subject: [PATCH 1/2] chore(NODE-4681): deprecate modify result --- src/collection.ts | 5 ++++- .../types/community/collection/findX.test-d.ts | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/collection.ts b/src/collection.ts index e22ce9eeca..5e4ec8a737 100644 --- a/src/collection.ts +++ b/src/collection.ts @@ -99,7 +99,10 @@ import { } from './utils'; import { WriteConcern, WriteConcernOptions } from './write_concern'; -/** @public */ +/** + * @public + * @deprecated Will return the actual result document in 5.0 + */ export interface ModifyResult { value: WithId | null; lastErrorObject?: Document; diff --git a/test/types/community/collection/findX.test-d.ts b/test/types/community/collection/findX.test-d.ts index 463ba1518e..9335249b6f 100644 --- a/test/types/community/collection/findX.test-d.ts +++ b/test/types/community/collection/findX.test-d.ts @@ -348,3 +348,21 @@ expectType | null>( expectType | null>( (await coll.findOneAndDelete({ a: 3 }, { projection: { _id: 0 } })).value ); + +// NODE-3568: Uncomment when ModifyResult is removed in 5.0 +// expectType | null>((await coll.findOneAndDelete({ a: 3 }))); +// expectType( +// (await coll.findOneAndReplace({ a: 3 }, { a: 5, b: 'new string' })) +// ); +// expectType( +// ( +// await coll.findOneAndUpdate( +// { a: 3 }, +// { +// $set: { +// a: 5 +// } +// } +// ) +// ) +// ); From fe8cfbbe6ab7c40809406b1bf2fd206a25188ff1 Mon Sep 17 00:00:00 2001 From: Durran Jordan Date: Tue, 8 Nov 2022 20:16:00 +0100 Subject: [PATCH 2/2] chore: update comments and commented out tests --- src/collection.ts | 4 +++- test/types/community/collection/findX.test-d.ts | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/collection.ts b/src/collection.ts index 5e4ec8a737..e3a5f43a95 100644 --- a/src/collection.ts +++ b/src/collection.ts @@ -101,7 +101,9 @@ import { WriteConcern, WriteConcernOptions } from './write_concern'; /** * @public - * @deprecated Will return the actual result document in 5.0 + * @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 { value: WithId | null; diff --git a/test/types/community/collection/findX.test-d.ts b/test/types/community/collection/findX.test-d.ts index 9335249b6f..733e1c83d3 100644 --- a/test/types/community/collection/findX.test-d.ts +++ b/test/types/community/collection/findX.test-d.ts @@ -350,11 +350,11 @@ expectType | null>( ); // NODE-3568: Uncomment when ModifyResult is removed in 5.0 -// expectType | null>((await coll.findOneAndDelete({ a: 3 }))); -// expectType( +// expectType | null> | null>((await coll.findOneAndDelete({ a: 3 }))); +// expectType | null>( // (await coll.findOneAndReplace({ a: 3 }, { a: 5, b: 'new string' })) // ); -// expectType( +// expectType | null>( // ( // await coll.findOneAndUpdate( // { a: 3 },