Ember Relationship Tracker is an Ember addon designed to track changes in Ember Data relationships, such as belongsTo
and hasMany
. It extends the functionality of Ember Data models by overwriting methods like hasDirtyAttributes
, changedAttributes
, rollbackAttributes
, and save
to include relationship changes.
- Ember.js v4.9 or above
- Ember CLI v4.9 or above
- Node.js v14 or above
ember install ember-relationship-tracker
To use the relationship tracker, extend your models from the BaseModel provided by the addon:
import TrackerModel from 'ember-relationship-tracker/models';
export default class MyModel extends TrackerModel {
// Your model attributes and methods here
}
The addon overrides the following methods to include relationship changes:
- saveInitialState: Save initialState. Note: if model is modified and saved, you may need to manually call this function
yourmodel.saveInitialState()
to update initialState. - hasDirtyAttributes: Checks if the model or any of its relationships have unsaved changes.
- changedAttributes: Returns an object containing the changed attributes and relationships.
- rollbackAttributes: Reverts the model and its relationships to their original state.
- save: Saves the model and its relationships.
See the Contributing guide for details.
This project is licensed under the MIT License.