home
  • Blog
  • Home
  • Projects
    • Ember
    • EmberData
    • Ember CLI
2.18
  • Packages
    • ember-data
  • Classes
    • DS.AbortError
    • DS.Adapter
    • DS.AdapterError
    • DS.AdapterPopulatedRecordArray
    • DS.BelongsToReference
    • DS.BooleanTransform
    • DS.BuildURLMixin
    • DS.ConflictError
    • DS.DateTransform
    • DS.EmbeddedRecordsMixin
    • DS.Errors
    • DS.FilteredRecordArray
    • DS.ForbiddenError
    • DS.HasManyReference
    • DS.InvalidError
    • DS.JSONAPIAdapter
    • DS.JSONAPISerializer
    • DS.JSONSerializer
    • DS.ManyArray
    • DS.Model
    • DS.NotFoundError
    • DS.NumberTransform
    • DS.PromiseArray
    • DS.PromiseManyArray
    • DS.PromiseObject
    • DS.RESTAdapter
    • DS.RESTSerializer
    • DS.RecordArray
    • DS.RecordReference
    • DS.RootState
    • DS.Serializer
    • DS.ServerError
    • DS.Store
    • DS.StringTransform
    • DS.TimeoutError
    • DS.Transform
    • DS.UnauthorizedError
    • Ember.Inflector

Class DS.RecordReference


Defined in: addon/-private/system/references/record.js:4
Module: ember-data

An RecordReference is a low level API that allows users and addon author to perform meta-operations on a record.


Methods

id : String

Module: ember-data

Defined in addon/-private/system/references/record.js:21

returns
String

The id of the record.

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'

load : Promise<record>

Module: ember-data

Defined in addon/-private/system/references/record.js:121

returns
Promise<record>

the record for this RecordReference

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(...)

push (UNKNOWN) :

Module: ember-data

Defined in addon/-private/system/references/record.js:62

UNKNOWN
Promise|Object
returns

Promise a promise for the value (record or relationship)

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, username: "@user" }}).then(function(user) {
   userRef.value() === user;
 });

reload : Promise<record>

Module: ember-data

Defined in addon/-private/system/references/record.js:141

returns
Promise<record>

the record for this RecordReference

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(...)

remoteType : String

Module: ember-data

Defined in addon/-private/system/references/record.js:42

returns
String

'identity'

How the reference will be looked up when it is loaded: Currently this always return identity to signifying that a record will be loaded by the type and id.

Example

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

userRef.remoteType(); // 'identity'

value : DS.Model

Module: ember-data

Defined in addon/-private/system/references/record.js:98

returns
DS.Model

the record for this RecordReference

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
On this page


Methods

  • id
  • load
  • push
  • reload
  • remoteType
  • value
Team Sponsors Security Legal Branding Community Guidelines
Twitter GitHub Discord Mastodon

If you want help you can contact us by email, open an issue, or get realtime help by joining the Ember Discord.

© Copyright 2025 - Tilde Inc.
Ember.js is free, open source and always will be.


Ember is generously supported by
blue Created with Sketch.