Model.deleteMany() and Model.deleteOne() does not return acknowledged #11211
Labels
confirmed-bug
We've confirmed this is a bug in Mongoose and will fix it.
Milestone
Do you want to request a feature or report a bug?
This is a bug - or perhaps just inconsistent documentation, I'm not entirely sure which is it.
What is the current behavior?
When calling
Model.deleteMany()
(orModel.deleteOne()
), the return result is{ deletedCount: 1 }
, and doesn't have theacknowledged
property.If the current behavior is a bug, please provide the steps to reproduce.
Simply call
Model.deleteMany()
on any model and observe the result. Sample script below:What is the expected behavior?
The v6 migration guide states that the result of
deleteMany
should have both theacknowledged
property and thedeletedCount
property. This is consistent with the TypeScript definitions, which indicate that the result of the deleteMany operation has bothdeletedCount
andacknowledged
.However, the deleteMany API documentation states that only
deletedCount
is returned, which is consistent with the implementation.If the intention is to not include
acknowledged
, then the migration guide and the TypeScript definitions should be updated. If the intention is to includeacknowledged
, then the implementation and the API documentation should be updated.What are the versions of Node.js, Mongoose and MongoDB you are using? Note that "latest" is not a version.
Node.js: v14.17.5
Mongoose: v6.1.6
MongoDB: 4.0.22
The text was updated successfully, but these errors were encountered: