Skip to content
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

document.remove() removes whole collection #3326

Closed
RBLU opened this issue Sep 1, 2015 · 7 comments
Closed

document.remove() removes whole collection #3326

RBLU opened this issue Sep 1, 2015 · 7 comments
Milestone

Comments

@RBLU
Copy link

RBLU commented Sep 1, 2015

I think this commit (caf7181) for a fix of model.remove() has triggered that now when we call:

document.remove(cb) 

everything in the collection is removed, previously only the one document was removed.
This can be pretty bad (my users collection was emtpy after deleting one user)... I hope my analysis is not correct.

Also the documentation here states clearly that the current behaviour is not intended: http://mongoosejs.com/docs/api.html#model_Model-remove
model.remove(fn) removes this document from the db.

RBLU added a commit to YouPers/backendlib that referenced this issue Sep 1, 2015
@vkarpov15
Copy link
Collaborator

Whoa yeah that's not terribly good. On it.

@vkarpov15 vkarpov15 added this to the 4.1.5 milestone Sep 1, 2015
@fyockm
Copy link
Contributor

fyockm commented Sep 1, 2015

duplicate of #3325

@farhanpatel
Copy link

This fix should be out now. This is pretty huge

@vkarpov15
Copy link
Collaborator

Done. Thanks.

@Martii
Copy link

Martii commented Sep 2, 2015

@vkarpov15
Perhaps a silly question... but is there an "unremove" (undelete) method?

@shauntrennery
Copy link

This got me this morning. Thank goodness for database backups. All our platform's apps were deleted. I even started to suspect we had been hacked.

@vkarpov15
Copy link
Collaborator

Sorry about that @shauntrennery - unfortunately we did not have test coverage for this situation and the fix for #3235 went awry. 4.1.4 has been unpublished so hopefully that'll limit the possibility of anybody running into this again...

@Martii not that I know of unfortunately. Typically it's a better choice to not explicitly delete individual docs and instead hide them behind an isDeleted flag for this sort of situation.

RBLU added a commit to YouPers/backendlib that referenced this issue Sep 4, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants