Skip to content
This repository has been archived by the owner on May 26, 2019. It is now read-only.

Update "rollback()" and "isDirty" references #806

Merged
merged 2 commits into from
Sep 25, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions source/models/creating-updating-and-deleting-records.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,33 +95,33 @@ store.findRecord('post', 1).then(function(post) {
```

You can tell if a record has outstanding changes that have not yet been
saved by checking its `isDirty` property. You can also see what parts of
saved by checking its `hasDirtyAttributes` property. You can also see what parts of
the record were changed and what the original value was using the
`changedAttributes` function. `changedAttributes` returns an object,
whose keys are the changed properties and values are an array of values
`[oldValue, newValue]`.

```js
person.get('isAdmin'); //=> false
person.get('isDirty'); //=> false
person.get('isAdmin'); //=> false
person.get('hasDirtyAttributes'); //=> false
person.set('isAdmin', true);
person.get('isDirty'); //=> true
person.changedAttributes(); //=> { isAdmin: [false, true] }
person.get('hasDirtyAttributes'); //=> true
person.changedAttributes(); //=> { isAdmin: [false, true] }
```

At this point, you can either persist your changes via `save()` or you
can rollback your changes. Calling `rollback()` reverts all the
can rollback your changes. Calling `rollbackAttributes()` reverts all the
`changedAttributes` to their original value.

```js
person.get('isDirty'); //=> true
person.changedAttributes(); //=> { isAdmin: [false, true] }
person.get('hasDirtyAttributes'); //=> true
person.changedAttributes(); //=> { isAdmin: [false, true] }

person.rollback();
person.rollbackAttributes();

person.get('isDirty'); //=> false
person.get('isAdmin'); //=> false
person.changedAttributes(); //=> {}
person.get('hasDirtyAttributes'); //=> false
person.get('isAdmin'); //=> false
person.changedAttributes(); //=> {}
```

## Promises
Expand Down