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 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
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 related data

When accessing ember-data relationships in your app, you can either ask for the related record asynchronously or synchronously.

It's possible to configure it through the ` async` option. The default value is `true`.

```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, you can [check out the official documentation on async relationships.](https://api.emberjs.com/ember-data/release/functions/@ember-data%2Fmodel/hasMany)

### Readonly Nested Data

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