camo
camo copied to clipboard
pre save hook does not save modifications
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?
This one it's duplicated with #43. See that for workarounds.
Fixed in https://github.com/scottwrobinson/camo/commit/beb5681010e1df6baed7bb826cd342665555bd10