Prerequisites
Mongoose version
8.20.1
Node.js version
24.5.0
MongoDB server version
8.0.3
Typescript version (if applicable)
5.9.3
Description
As the documentation says:
The Model.prototype.deleteOne() method sets $isDeleted if the delete operation succeeded.
But it doesn't. The $isDeleted() method returns false after calling the deleteOne() method and the document has been deleted successfully.
The example given in documentation cannot be run because the product variable cannot be redeclared.
TS2451: Cannot redeclare block-scoped variable product
The deleteOne() method returns DeleteResult not the document itself.
The way I achived the expected result is:
await product.deleteOne();
product.$isDeleted(true);
And after I can check whether the document has been deleted or not.
Steps to Reproduce
Follow the example on the documentation page.
Expected Behavior
The $isDeleted() method returns true after calling deleteOne() on the document and it has been successfully deleted from the database.
Prerequisites
Mongoose version
8.20.1
Node.js version
24.5.0
MongoDB server version
8.0.3
Typescript version (if applicable)
5.9.3
Description
As the documentation says:
But it doesn't. The
$isDeleted()method returnsfalseafter calling thedeleteOne()method and the document has been deleted successfully.The example given in documentation cannot be run because the product variable cannot be redeclared.
The
deleteOne()method returns DeleteResult not the document itself.The way I achived the expected result is:
And after I can check whether the document has been deleted or not.
Steps to Reproduce
Follow the example on the documentation page.
Expected Behavior
The
$isDeleted()method returnstrueafter callingdeleteOne()on the document and it has been successfully deleted from the database.