-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Model.restore is broken when using use$neOperator = false #14338
Comments
This GitHub repo is for mongoose, not mongoose-delete, so it would likely be better to report this as a bug on the mongoose-delete GitHub repo. That being said, this does look like an unintentional bug introduced in mongoose-delete. We will see if we can open a PR to fix |
My apologies @vkarpov15 ... silly mistake! Thank you so much! |
I think this issue can be closed since it indeed relates to |
I prefer to keep this open until the mongoose-delete PR is merged so we can remember to follow up on it |
Prerequisites
Mongoose version
7.4.2
Node.js version
20.11
MongoDB server version
5.0.24
Typescript version (if applicable)
No response
Description
We have noticed that the
Model.restore
is removing the fielddeleted
from the document.This previously used to work.
We are using the
use$neOperator
with a value offalse
- in other words, all of our queries look for data wheredeleted = false
as a result of dsanel/mongoose-delete#50.The following change, made in version 1.0.1 has broken this functionality:
Before this code change, the
schema.statics.restore
was:After this code change, the function is:
The issue here, is that the
deleted
key is being removed from the model, which doesn't support how theuse$neOperator
works!I have tested the following which appears to work - could this be considered for the 7.6.x release please?
Steps to Reproduce
Configure the
mongoose-delete
plugin as follows:When you add this plugin to your schema, delete a document, and then try to restore it:
The
deleted
key has been removed from the underlying document.Expected Behavior
The deleted key should remain in the document, and have a value of
false
The text was updated successfully, but these errors were encountered: