store.peekRecord()
Returns a record from the local cache without making a network request.
Syntax
store.peekRecord(type, id): Model | null Parameters
| Name | Type | Required | Description |
|---|---|---|---|
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.