Model.restore( ) method bug .
When using this method it does not change the value of deleted field in mongodb to false instead it deletes this field.
Fixed here: https://github.com/dsanel/mongoose-delete/pull/157
Depending on wether use$neOperator is set to true or false we get defective results either way at the moment:
use$neOperator: false countDocuments (1), countDocumentsWithDeleted (6), countDocumentsDeleted (5) ==> restore() countDocuments (1), countDocumentsWithDeleted (6), countDocumentsDeleted (3) --> countDocuments should be (3)!
use$neOperator: true countDocuments (1), countDocumentsWithDeleted (6), countDocumentsDeleted (5) ==> restore() countDocuments (3), countDocumentsWithDeleted (6), countDocumentsDeleted (5) --> countDocumentsDeleted should be (3)
It would be great if that/a solution could be published soon :) Thanks!
if u still having this issue, based on this snippets, u should query the schema first and call restore() afterwards.
const restored = await documentModel.findOneDeleted({ _id: id })
restored?.restore()
this will make the deleted: false. otherwise
await documentModel.restore({ _id: id })
this will make the deleted attribute become undefined
Hey @dsanel would you be willing to make some of us maintainers of this repository and the npm package so we can release some of the fixes from open PRs?