@@ -100,12 +100,7 @@ import {
100
100
} from './utils' ;
101
101
import { WriteConcern , type WriteConcernOptions } from './write_concern' ;
102
102
103
- /**
104
- * @public
105
- * @deprecated This type will be completely removed and findOneAndUpdate,
106
- * findOneAndDelete, and findOneAndReplace will then return the
107
- * actual result document.
108
- */
103
+ /** @public */
109
104
export interface ModifyResult < TSchema = Document > {
110
105
value : WithId < TSchema > | null ;
111
106
lastErrorObject ?: Document ;
@@ -825,10 +820,23 @@ export class Collection<TSchema extends Document = Document> {
825
820
* @param filter - The filter used to select the document to remove
826
821
* @param options - Optional settings for the command
827
822
*/
823
+ async findOneAndDelete (
824
+ filter : Filter < TSchema > ,
825
+ options : FindOneAndDeleteOptions & { includeResultMetadata : true }
826
+ ) : Promise < ModifyResult < TSchema > > ;
827
+ async findOneAndDelete (
828
+ filter : Filter < TSchema > ,
829
+ options : FindOneAndDeleteOptions & { includeResultMetadata : false }
830
+ ) : Promise < WithId < TSchema > | null > ;
831
+ async findOneAndDelete (
832
+ filter : Filter < TSchema > ,
833
+ options : FindOneAndDeleteOptions
834
+ ) : Promise < ModifyResult < TSchema > > ;
835
+ async findOneAndDelete ( filter : Filter < TSchema > ) : Promise < ModifyResult < TSchema > > ;
828
836
async findOneAndDelete (
829
837
filter : Filter < TSchema > ,
830
838
options ?: FindOneAndDeleteOptions
831
- ) : Promise < ModifyResult < TSchema > > {
839
+ ) : Promise < WithId < TSchema > | ModifyResult < TSchema > | null > {
832
840
return executeOperation (
833
841
this . client ,
834
842
new FindOneAndDeleteOperation (
@@ -846,11 +854,30 @@ export class Collection<TSchema extends Document = Document> {
846
854
* @param replacement - The Document that replaces the matching document
847
855
* @param options - Optional settings for the command
848
856
*/
857
+ async findOneAndReplace (
858
+ filter : Filter < TSchema > ,
859
+ replacement : WithoutId < TSchema > ,
860
+ options : FindOneAndReplaceOptions & { includeResultMetadata : true }
861
+ ) : Promise < ModifyResult < TSchema > > ;
862
+ async findOneAndReplace (
863
+ filter : Filter < TSchema > ,
864
+ replacement : WithoutId < TSchema > ,
865
+ options : FindOneAndReplaceOptions & { includeResultMetadata : false }
866
+ ) : Promise < WithId < TSchema > | null > ;
867
+ async findOneAndReplace (
868
+ filter : Filter < TSchema > ,
869
+ replacement : WithoutId < TSchema > ,
870
+ options : FindOneAndReplaceOptions
871
+ ) : Promise < ModifyResult < TSchema > > ;
872
+ async findOneAndReplace (
873
+ filter : Filter < TSchema > ,
874
+ replacement : WithoutId < TSchema >
875
+ ) : Promise < ModifyResult < TSchema > > ;
849
876
async findOneAndReplace (
850
877
filter : Filter < TSchema > ,
851
878
replacement : WithoutId < TSchema > ,
852
879
options ?: FindOneAndReplaceOptions
853
- ) : Promise < ModifyResult < TSchema > > {
880
+ ) : Promise < WithId < TSchema > | ModifyResult < TSchema > | null > {
854
881
return executeOperation (
855
882
this . client ,
856
883
new FindOneAndReplaceOperation (
@@ -869,11 +896,30 @@ export class Collection<TSchema extends Document = Document> {
869
896
* @param update - Update operations to be performed on the document
870
897
* @param options - Optional settings for the command
871
898
*/
899
+ async findOneAndUpdate (
900
+ filter : Filter < TSchema > ,
901
+ update : UpdateFilter < TSchema > ,
902
+ options : FindOneAndUpdateOptions & { includeResultMetadata : true }
903
+ ) : Promise < ModifyResult < TSchema > > ;
904
+ async findOneAndUpdate (
905
+ filter : Filter < TSchema > ,
906
+ update : UpdateFilter < TSchema > ,
907
+ options : FindOneAndUpdateOptions & { includeResultMetadata : false }
908
+ ) : Promise < WithId < TSchema > | null > ;
909
+ async findOneAndUpdate (
910
+ filter : Filter < TSchema > ,
911
+ update : UpdateFilter < TSchema > ,
912
+ options : FindOneAndUpdateOptions
913
+ ) : Promise < ModifyResult < TSchema > > ;
914
+ async findOneAndUpdate (
915
+ filter : Filter < TSchema > ,
916
+ update : UpdateFilter < TSchema >
917
+ ) : Promise < ModifyResult < TSchema > > ;
872
918
async findOneAndUpdate (
873
919
filter : Filter < TSchema > ,
874
920
update : UpdateFilter < TSchema > ,
875
921
options ?: FindOneAndUpdateOptions
876
- ) : Promise < ModifyResult < TSchema > > {
922
+ ) : Promise < WithId < TSchema > | ModifyResult < TSchema > | null > {
877
923
return executeOperation (
878
924
this . client ,
879
925
new FindOneAndUpdateOperation (
0 commit comments