File tree Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change 9
9
HydratedSingleSubdocument ,
10
10
DefaultSchemaOptions
11
11
} from 'mongoose' ;
12
+ import { DeleteResult } from 'mongodb' ;
12
13
import { expectAssignable , expectError , expectType } from 'tsd' ;
13
14
import { autoTypedModel } from './models.test' ;
14
15
import { autoTypedModelConnection } from './connection.test' ;
@@ -39,7 +40,9 @@ const Test = model<ITest>('Test', schema);
39
40
void async function main ( ) {
40
41
const doc = await Test . findOne ( ) . orFail ( ) ;
41
42
42
- expectType < Promise < TestDocument > > ( doc . deleteOne ( ) ) ;
43
+ expectType < DeleteResult > ( await doc . deleteOne ( ) ) ;
44
+ expectType < TestDocument | null > ( await doc . deleteOne ( ) . findOne ( ) ) ;
45
+ expectType < { _id : Types . ObjectId , name ?: string } | null > ( await doc . deleteOne ( ) . findOne ( ) . lean ( ) ) ;
43
46
} ( ) ;
44
47
45
48
Original file line number Diff line number Diff line change @@ -108,7 +108,13 @@ declare module 'mongoose' {
108
108
db : Connection ;
109
109
110
110
/** Removes this document from the db. */
111
- deleteOne ( options ?: QueryOptions ) : Promise < this> ;
111
+ deleteOne ( options ?: QueryOptions ) : QueryWithHelpers <
112
+ mongodb . DeleteResult ,
113
+ this,
114
+ TQueryHelpers ,
115
+ DocType ,
116
+ 'deleteOne'
117
+ > ;
112
118
113
119
/**
114
120
* Takes a populated field and returns it to its unpopulated state. If called with
You can’t perform that action at this time.
0 commit comments