# ember-data-relationship-dirty-tracking

> Dirty tracking for ember-data relationships

Latest version **0.2.0** (published 2024-02-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install ember-data-relationship-dirty-tracking
pnpm add ember-data-relationship-dirty-tracking
yarn add ember-data-relationship-dirty-tracking
bun add ember-data-relationship-dirty-tracking
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2024-02-13 |
| First published | 2024-02-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | 14.* \|\| 16.* \|\| >= 18 |
| Dependencies | 3 |
| Unpacked size | 14.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Derek Wickern |
| Maintainers | dwickern |
| Keywords | ember-addon |

## Links

- npm: https://www.npmjs.com/package/ember-data-relationship-dirty-tracking
- Repository: https://github.com/dwickern/ember-data-relationship-dirty-tracking
- Homepage: https://github.com/dwickern/ember-data-relationship-dirty-tracking#readme
- Issues: https://github.com/dwickern/ember-data-relationship-dirty-tracking/issues
- npm.io page: https://npm.io/package/ember-data-relationship-dirty-tracking

## Dependencies (3)

- [ember-cli-babel](https://npm.io/package/ember-cli-babel.md) ^7.26.11
- [@embroider/macros](https://npm.io/package/@embroider/macros.md) ^1.13.5
- [ember-cli-htmlbars](https://npm.io/package/ember-cli-htmlbars.md) ^6.2.0

## Recent versions

- 0.2.0 (latest) — 2024-02-13

## README

# ember-data-relationship-dirty-tracking

Dirty tracking for ember-data relationships.

## Compatibility

* Ember.js v4.4 or above
* Ember CLI v4.4 or above
* Node.js v14 or above
* Ember-data 3.28 - 4.6


## Installation

```
ember install ember-data-relationship-dirty-tracking
```

## Usage

All relationships are tracked by default.
After modifying a relationship, the model's [hasDirtyAttributes] property will become `true`.

Use the `dirtyTracking` option to disable dirty tracking for specific relationships: 

```js
// app/models/blog-post.js
import Model, { belongsTo, hasMany } from '@ember-data/model';

export default class BlogPostModel extends Model {
  @belongsTo('author', { dirtyTracking: false }) author;
  @hasMany('comment', { dirtyTracking: false }) comments;
}
```

### Inverse Relationships

This addon does not support dirty tracking for inverse relationships.

Pick one side of the relationship to be the primary side.
Modify the relationship from this side only.

Mark the other side of the relationship with `dirtyTracking: false`.
Do not modify the relationship from this side.

For example:
```js
// app/models/blog-post.js
import Model, { hasMany } from '@ember-data/model';

export default class BlogPostModel extends Model {
  // modify the relationship through this property
  @hasMany('tag') tags;
}
```
```js
// app/models/tag.js
import Model, { hasMany } from '@ember-data/model';

export default class TagModel extends Model {
  // treat this property as read-only
  @hasMany('blog-post', { dirtyTracking: false }) blogPosts;
}
```

## Contributing

See the [Contributing](CONTRIBUTING.md) guide for details.


## License

This project is licensed under the [MIT License](LICENSE.md).

[hasDirtyAttributes]: https://api.emberjs.com/ember-data/3.28/classes/Model/properties/hasDirtyAttributes?anchor=hasDirtyAttributes

---
_Source: https://npm.io/package/ember-data-relationship-dirty-tracking · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
