store.findRecord()
Fetches a single record by type and id, using the cache when possible.
Syntax
store.findRecord(type, id, options?): Promise<Model> Parameters
| Name | Type | Required | Description |
|---|---|---|---|
type | string | No | The model name. |
id | string | No | The record id. |
options | object | No | Options like reload and include. |
Returns
Promise<Model> — Resolves to the record.
Throws
AdapterError— Rejected when the record cannot be fetched (e.g. 404).
Examples
import Route from '@ember/routing/route';
import { service } from '@ember/service';
export default class PostRoute extends Route {
@service store;
model(params) {
return this.store.findRecord('post', params.post_id, {
include: 'comments,author',
});
}
}
Notes
Returns a cached record immediately if present and reloads in the
background; pass { reload: true } to force a network fetch or
{ backgroundReload: false } to disable the refresh.