Class Reference

public

This is the baseClass for the different References like RecordReference/HasManyReference/BelongsToReference

Show:

returns
String
The link Ember Data will use to fetch or reload this belongs-to relationship.

The link Ember Data will use to fetch or reload this belongs-to relationship. By default it uses only the "related" resource linkage.

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// models/blog.js
import Model, { belongsTo } from '@ember-data/model';
export default Model.extend({
   user: belongsTo({ async: true })
 });

let blog = store.push({
   data: {
     type: 'blog',
     id: 1,
     relationships: {
       user: {
         links: {
           related: '/articles/1/author'
         }
       }
     }
   }
 });
let userRef = blog.belongsTo('user');

// get the identifier of the reference
if (userRef.remoteType() === "link") {
   let link = userRef.link();
 }
returns
Object
The meta information for the belongs-to relationship.

The meta data for the belongs-to relationship.

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// models/blog.js
import Model, { belongsTo } from '@ember-data/model';
export default Model.extend({
   user: belongsTo({ async: true })
 });

let blog = store.push({
   data: {
     type: 'blog',
     id: 1,
     relationships: {
       user: {
         links: {
           related: {
             href: '/articles/1/author'
           },
         },
         meta: {
           lastUpdated: 1458014400000
         }
       }
     }
   }
 });

let userRef = blog.belongsTo('user');

userRef.meta() // { lastUpdated: 1458014400000 }
returns
String
The name of the remote type. This should either be "link" or "ids"

This returns a string that represents how the reference will be looked up when it is loaded. If the relationship has a link it will use the "link" otherwise it defaults to "id".

Example

app/models/post.js
1
2
3
4
5
import Model, { hasMany } from '@ember-data/model';

export default Model.extend({
  comments: hasMany({ async: true })
});
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
let post = store.push({
  data: {
    type: 'post',
    id: 1,
    relationships: {
      comments: {
        data: [{ type: 'comment', id: 1 }]
      }
    }
  }
});

let commentsRef = post.hasMany('comments');

// get the identifier of the reference
if (commentsRef.remoteType() === "ids") {
  let ids = commentsRef.ids();
} else if (commentsRef.remoteType() === "link") {
  let link = commentsRef.link();
}