Add findByIdAndDelete() method (#28893)

findByIdAndDelete() recommended method is missing.

Mongoose docs:
https://mongoosejs.com/docs/api.html#model_Model.findByIdAndDelete

MongoDb docs:
https://docs.mongodb.com/manual/reference/method/db.collection.findOneAndDelete/
This commit is contained in:
Dyma
2018-09-14 19:22:28 +02:00
committed by Ryan Cavanaugh
parent a3b7777878
commit c43bcd9fd7

View File

@@ -2759,6 +2759,24 @@ declare module "mongoose" {
/** sets the document fields to return */
select?: any;
}, callback?: (err: any, res: T | null) => void): DocumentQuery<T | null, T>;
/**
* 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<T | null, T>;
findByIdAndDelete(id: any | number | string,
callback?: (err: any, res: T | null) => void): DocumentQuery<T | null, T>;
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<T | null, T>;
/**
* Issues a mongodb findAndModify update command by a document's _id field. findByIdAndUpdate(id, ...)