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

Model.save() resets internal modified state on error #2013

Closed
glebkhol opened this issue Apr 9, 2014 · 0 comments
Closed

Model.save() resets internal modified state on error #2013

glebkhol opened this issue Apr 9, 2014 · 0 comments

Comments

@glebkhol
Copy link

glebkhol commented Apr 9, 2014

Model.save() resets internal modified state even if Model.update() it calls is unsuccessful. This makes it impossible to handle E11001 "duplicate key on insert" by retrying saving a document again.

In the excerpt of Model.save() below, one can see that modified state is reset unconditionally prior to the update operation.

    if (delta) {
      if (delta instanceof Error) return complete(delta);
      var where = this.$__where(delta[0]);
      this.$__reset();
      this.collection.update(where, delta[1], options, complete);
    } else {
      this.$__reset();
      complete(null);
    }
@Uzlopak Uzlopak closed this as completed May 2, 2022
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

2 participants