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 {
createRecord (hash) Model public
Defined in ../packages/model/src/-private/many-array.ts:332
- hash
- Object
- returns
- Model
record
Create a child record within the owner
reload public
Defined in ../packages/model/src/-private/many-array.ts:286
Reloads all of the records in the manyArray. If the manyArray holds a relationship that was originally fetched using a links url Ember Data will revisit the original links url to repopulate the relationship.
If the manyArray holds the result of a store.query()
reload will
re-run the original query.
Example
let user = store.peekRecord('user', '1')
await login(user);
let permissions = await user.permissions;
await permissions.reload();
save PromiseArray public
Defined in ../packages/model/src/-private/many-array.ts:313
- returns
- PromiseArray
promise
Saves all of the records in the ManyArray
.
Example
let inbox = await store.findRecord('inbox', '1');
let messages = await inbox.messages;
messages.forEach((message) => {
message.isRead = true;
});
messages.save();