store.peekRecord()

Returns a record from the local cache without making a network request.

Since Ember 4/5 (Octane) Spec ↗

Syntax

store.peekRecord(type, id): Model | null

Parameters

NameTypeRequiredDescription
type string No The model name.
id string No The record id.

Returns

Model | null — The cached record or null if absent.

Examples

import Component from '@glimmer/component';
import { service } from '@ember/service';

export default class PostBadgeComponent extends Component {
  @service store;

  get post() {
    return this.store.peekRecord('post', this.args.id);
  }
}

Notes

Synchronous and cache-only: returns null if the record has not been loaded. Use it to avoid redundant fetches when you know the record is already present; otherwise use findRecord.