Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update doc regarding async relationships #1817

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
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
22 changes: 22 additions & 0 deletions guides/release/models/relationships.md
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,28 @@ And our API might setup these relationships like so:
}
```

### Accessing relationship
PaulRosset marked this conversation as resolved.
Show resolved Hide resolved

When accessing ember-data relationship in your app, you can either ask for accessing the relation asynchronously or synchronously.
PaulRosset marked this conversation as resolved.
Show resolved Hide resolved

It's possible to configure it through the `{ async: boolean }` property.
PaulRosset marked this conversation as resolved.
Show resolved Hide resolved

```javascript {data-filename=app/models/organization.js}
import Model, { hasMany } from '@ember-data/model';

export default class OrganizationModel extends Model {
@hasMany('membership', { async: false }) memberships;
}
```

Thus, later in your app, you will be able to access the relationship like so:

```javascript
let memberships = organization.get('memberships');
```

For more information about async relationships, you can [check out the official documentation.](https://api.emberjs.com/ember-data/release/functions/@ember-data%2Fmodel/hasMany)
PaulRosset marked this conversation as resolved.
Show resolved Hide resolved

### Readonly Nested Data

Some models may have properties that are deeply nested objects of
Expand Down