hasMany (keyName, options) (Array|undefined)
Returns the current value of a hasMany relationship.
hasMany
takes an optional hash of options as a second parameter, currently supported options are:
-
ids
: set totrue
if you only want the IDs of the related records to be returned.
Example
// store.push('post', { id: 1, title: 'Hello World', comments: [2, 3] }); postSnapshot.hasMany('comments'); // => [DS.Snapshot, DS.Snapshot] postSnapshot.hasMany('comments', { ids: true }); // => ['2', '3'] // store.push('post', { id: 1, title: 'Hello World' }); postSnapshot.hasMany('comments'); // => undefined
Note: Relationships are loaded lazily and cached upon first access.
Parameters:
-
keyName
String
-
options
[Object]
Returns:
-
(Array|undefined)
- An array of snapshots or IDs of a known relationship or an empty array if the relationship is known but unset. undefined will be returned if the contents of the relationship is unknown.
Please login to continue.