Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/collection.ts
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
// }
// }
// )
// )
// );