#

API Docs for: v3.16.0-alpha.2
Show: Inherited Protected Private Deprecated

# RecordReference Class

Extends Reference
Defined in: `../store/addon/-private/system/references/record.ts:10`
Module: @ember-data/store

A `RecordReference` is a low-level API that allows users and addon authors to perform meta-operations on a record.

- Index
- Methods

## Item Index

### Methods

- id
- link
- load
- meta
- push
- reload
- remoteType
- value

## Methods

### `id`

() String

Defined in `../store/addon/-private/system/references/record.ts:23`

The `id` of the record that this reference refers to.

Together, the `type` and `id` properties form a composite key for the identity map.

Example

    let userRef = store.getReference('user', 1);

    userRef.id(); // '1'

#### Returns:

String:

The id of the record.

### `link`

() String

Inherited from Reference: `../store/addon/-private/system/references/reference.ts:93`

The link Ember Data will use to fetch or reload this belongs-to relationship. Example ```javascript // 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:

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

### `load`

() Promise

Defined in `../store/addon/-private/system/references/record.ts:131`

Triggers a fetch for the backing entity based on its `remoteType` (see `remoteType` definitions per reference type).

Example

    let userRef = store.getReference('user', 1);

    // load user (via store.find)
    userRef.load().then(...)

#### Returns:

Promise:

the record for this RecordReference

### `meta`

() Object

Inherited from Reference: `../store/addon/-private/system/references/reference.ts:143`

The meta data for the belongs-to relationship. Example ```javascript // 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:

Object: The meta information for the belongs-to relationship.

### `push`

(

- `objectOrPromise`

)

Defined in `../store/addon/-private/system/references/record.ts:64`

This API allows you to provide a reference with new data. The simplest usage of this API is similar to `store.push`: you provide a normalized hash of data and the object represented by the reference will update.

If you pass a promise to `push`, Ember Data will not ask the adapter for the data if another attempt to fetch it is made in the interim. When the promise resolves, the underlying object is updated with the new data, and the promise returned by this function is resolved with that object.

For example, `recordReference.push(promise)` will be resolved with a record.

Example

    let userRef = store.getReference('user', 1);

    // provide data for reference
    userRef.push({
      data: {
        id: "1",
        type: "user",
        attributes: {
          username: "@user"
        }
      }
    }).then(function(user) {
      userRef.value() === user;
    });

#### Parameters:

- `objectOrPromise` Object

  a JSON:API ResourceDocument or a promise resolving to one

#### Returns:

a promise for the value (record or relationship)

### `reload`

() Promise

Defined in `../store/addon/-private/system/references/record.ts:154`

Reloads the record if it is already loaded. If the record is not loaded it will load the record via `store.findRecord`

Example

    let userRef = store.getReference('user', 1);

    // or trigger a reload
    userRef.reload().then(...)

#### Returns:

Promise:

the record for this RecordReference

### `remoteType`

() String

Inherited from Reference but overwritten in `../store/addon/-private/system/references/record.ts:44`

How the reference will be looked up when it is loaded. Currently this always returns `identity` to signify that a record will be loaded by its `type` and `id`.

Example

    const userRef = store.getReference('user', 1);

    userRef.remoteType(); // 'identity'

#### Returns:

String:

'identity'

### `value`

() Model

Defined in `../store/addon/-private/system/references/record.ts:108`

If the entity referred to by the reference is already loaded, it is present as `reference.value`. Otherwise the value returned by this function is `null`.

Example

    let userRef = store.getReference('user', 1);

    userRef.value(); // user

#### Returns:

Model:

the record for this RecordReference