diff --git a/types/mongoose/index.d.ts b/types/mongoose/index.d.ts index 3534f82f49..70a4247d07 100644 --- a/types/mongoose/index.d.ts +++ b/types/mongoose/index.d.ts @@ -2759,6 +2759,24 @@ declare module "mongoose" { /** sets the document fields to return */ select?: any; }, callback?: (err: any, res: T | null) => void): DocumentQuery; + + + /** + * Issue a mongodb findOneAndDelete command by a document's _id field. + * findByIdAndDelete(id, ...) is equivalent to findByIdAndDelete({ _id: id }, ...). + * Finds a matching document, removes it, passing the found document (if any) to the callback. + * Executes immediately if callback is passed, else a Query object is returned. + * @param id value of _id to query by + */ + findByIdAndDelete(): DocumentQuery; + findByIdAndDelete(id: any | number | string, + callback?: (err: any, res: T | null) => void): DocumentQuery; + findByIdAndDelete(id: any | number | string, options: { + /** if multiple docs are found by the conditions, sets the sort order to choose which doc to update */ + sort?: any; + /** sets the document fields to return */ + select?: any; + }, callback?: (err: any, res: T | null) => void): DocumentQuery; /** * Issues a mongodb findAndModify update command by a document's _id field. findByIdAndUpdate(id, ...)