Class ManyArray
publicA ManyArray
is a MutableArray
that represents the contents of a has-many
relationship.
The ManyArray
is instantiated lazily the first time the relationship is
requested.
This class is not intended to be directly instantiated by consuming applications.
Inverses
Often, the relationships in Ember Data applications will have an inverse. For example, imagine the following models are defined:
```js {data-filename=app/models/post.js} import Model, { hasMany } from '@ember-data/model';
export default class PostModel extends Model {
isLoaded public
Defined in ../packages/model/src/-private/many-array.ts:90
The loading state of this array
links public
Defined in ../packages/model/src/-private/many-array.ts:144
Retrieve the links for this relationship
meta public
Defined in ../packages/model/src/-private/many-array.ts:106
Metadata associated with the request for async hasMany relationships.
Example
Given that the server returns the following JSON payload when fetching a hasMany relationship:
{
"comments": [{
"id": 1,
"comment": "This is the first comment",
}, {
// ...
}],
"meta": {
"page": 1,
"total": 5
}
}
You can then access the meta data via the meta
property:
let comments = await post.comments;
let meta = comments.meta;
// meta.page => 1
// meta.total => 5