Skip to content

rollbackAttributes() only rolls back one change #57

Open
@therealcljohn

Description

@therealcljohn

Hi,

I have a use case where I need to rollback all attributes of a model to their last saved state. In the code of the JsonApiModel I found the method rollbackAttributes() which I excpected to do the job. But when doing two changes on a model attribute it only rolls back one change and not two changes.

Example:

let test = this.datastoreService.createRecord(Role, {});
test.name = "test";
test.save();
console.log(test.name); // prints "test"
test.name = "test2";
test.name = "test22";
test.rollbackAttributes();
console.log(test.name); //prints "test2" but I expected it to print "test"

Is this a bug or expected behaviour? If it's a bug I would like to propose a fix in the saveAnnotations() method of the Attribute decorator and make a pull request.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions