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

pre save hook does not save modifications #80

Open
SteveEmmerich opened this issue Jun 28, 2016 · 2 comments
Open

pre save hook does not save modifications #80

SteveEmmerich opened this issue Jun 28, 2016 · 2 comments

Comments

@SteveEmmerich
Copy link

When making changed to the instance in the pre save hook the changes are not saved to the db.
example (pseudo code):

class Dog extends Document {
  constructor() {
    super();
    this.name = String;
  }
  preSave()
  {
    this.name = this.name + "_dog";
  }
};

var dog = Dog.create({name: 'fido'});
dog.save();
Dog.find({})
  .then(
    function(obj)
    {
      console.log(obj.name);
    });

output:
"fido"

but it should be "fido_dog"

Or was this done on purpose?

@michaeljota
Copy link

This one it's duplicated with #43. See that for workarounds.

@caseyWebb
Copy link
Contributor

Fixed in beb5681

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

3 participants