Documentation / @ember-data/active-record / findRecord
Call Signature
function findRecord<T>(identifier, options?): FindRecordRequestOptions<FindRecordResultDocument<T>, T>;
Defined in: find-record.ts:70
Builds request options to fetch a single resource by a known id or identifier configured for the url and header expectations of most ActiveRecord APIs.
Basic Usage
import { findRecord } from '@ember-data/active-record/request';
const data = await store.request(findRecord('person', '1'));
With Options
import { findRecord } from '@ember-data/active-record/request';
const options = findRecord('person', '1', { include: ['pets', 'friends'] });
const data = await store.request(options);
With an Identifier
import { findRecord } from '@ember-data/active-record/request';
const options = findRecord({ type: 'person', id: '1' }, { include: ['pets', 'friends'] });
const data = await store.request(options);
Supplying Options to Modify the Request Behavior
The following options are supported:
host
- The host to use for the request, defaults to thehost
configured withsetBuildURLConfig
.namespace
- The namespace to use for the request, defaults to thenamespace
configured withsetBuildURLConfig
.resourcePath
- The resource path to use for the request, defaults to pluralizing and underscoring the supplied typereload
- Whether to forcibly reload the request if it is already in the store, not supplying this option will delegate to the store's CachePolicy, defaulting tofalse
if none is configured.backgroundReload
- Whether to reload the request if it is already in the store, but to also resolve the promise with the cached value, not supplying this option will delegate to the store's CachePolicy, defaulting tofalse
if none is configured.urlParamsSetting
- an object containing options for how to serialize the query params (seebuildQueryParams
)
import { findRecord } from '@ember-data/active-record/request';
const options = findRecord('person', '1', { include: ['pets', 'friends'] }, { namespace: 'api/v2' });
const data = await store.request(options);
Type Parameters
T
T
Parameters
identifier
RemotelyAccessibleIdentifier
<TypeFromInstance
<T
>>
options?
Returns
FindRecordRequestOptions
<FindRecordResultDocument
<T
>, T
>
Call Signature
function findRecord(identifier, options?): FindRecordRequestOptions;
Defined in: find-record.ts:74
Builds request options to fetch a single resource by a known id or identifier configured for the url and header expectations of most ActiveRecord APIs.
Basic Usage
import { findRecord } from '@ember-data/active-record/request';
const data = await store.request(findRecord('person', '1'));
With Options
import { findRecord } from '@ember-data/active-record/request';
const options = findRecord('person', '1', { include: ['pets', 'friends'] });
const data = await store.request(options);
With an Identifier
import { findRecord } from '@ember-data/active-record/request';
const options = findRecord({ type: 'person', id: '1' }, { include: ['pets', 'friends'] });
const data = await store.request(options);
Supplying Options to Modify the Request Behavior
The following options are supported:
host
- The host to use for the request, defaults to thehost
configured withsetBuildURLConfig
.namespace
- The namespace to use for the request, defaults to thenamespace
configured withsetBuildURLConfig
.resourcePath
- The resource path to use for the request, defaults to pluralizing and underscoring the supplied typereload
- Whether to forcibly reload the request if it is already in the store, not supplying this option will delegate to the store's CachePolicy, defaulting tofalse
if none is configured.backgroundReload
- Whether to reload the request if it is already in the store, but to also resolve the promise with the cached value, not supplying this option will delegate to the store's CachePolicy, defaulting tofalse
if none is configured.urlParamsSetting
- an object containing options for how to serialize the query params (seebuildQueryParams
)
import { findRecord } from '@ember-data/active-record/request';
const options = findRecord('person', '1', { include: ['pets', 'friends'] }, { namespace: 'api/v2' });
const data = await store.request(options);
Parameters
identifier
options?
Returns
Call Signature
function findRecord<T>(
type,
id,
options?): FindRecordRequestOptions<FindRecordResultDocument<T>, T>;
Defined in: find-record.ts:78
Builds request options to fetch a single resource by a known id or identifier configured for the url and header expectations of most ActiveRecord APIs.
Basic Usage
import { findRecord } from '@ember-data/active-record/request';
const data = await store.request(findRecord('person', '1'));
With Options
import { findRecord } from '@ember-data/active-record/request';
const options = findRecord('person', '1', { include: ['pets', 'friends'] });
const data = await store.request(options);
With an Identifier
import { findRecord } from '@ember-data/active-record/request';
const options = findRecord({ type: 'person', id: '1' }, { include: ['pets', 'friends'] });
const data = await store.request(options);
Supplying Options to Modify the Request Behavior
The following options are supported:
host
- The host to use for the request, defaults to thehost
configured withsetBuildURLConfig
.namespace
- The namespace to use for the request, defaults to thenamespace
configured withsetBuildURLConfig
.resourcePath
- The resource path to use for the request, defaults to pluralizing and underscoring the supplied typereload
- Whether to forcibly reload the request if it is already in the store, not supplying this option will delegate to the store's CachePolicy, defaulting tofalse
if none is configured.backgroundReload
- Whether to reload the request if it is already in the store, but to also resolve the promise with the cached value, not supplying this option will delegate to the store's CachePolicy, defaulting tofalse
if none is configured.urlParamsSetting
- an object containing options for how to serialize the query params (seebuildQueryParams
)
import { findRecord } from '@ember-data/active-record/request';
const options = findRecord('person', '1', { include: ['pets', 'friends'] }, { namespace: 'api/v2' });
const data = await store.request(options);
Type Parameters
T
T
Parameters
type
id
string
options?
Returns
FindRecordRequestOptions
<FindRecordResultDocument
<T
>, T
>
Call Signature
function findRecord(
type,
id,
options?): FindRecordRequestOptions;
Defined in: find-record.ts:83
Builds request options to fetch a single resource by a known id or identifier configured for the url and header expectations of most ActiveRecord APIs.
Basic Usage
import { findRecord } from '@ember-data/active-record/request';
const data = await store.request(findRecord('person', '1'));
With Options
import { findRecord } from '@ember-data/active-record/request';
const options = findRecord('person', '1', { include: ['pets', 'friends'] });
const data = await store.request(options);
With an Identifier
import { findRecord } from '@ember-data/active-record/request';
const options = findRecord({ type: 'person', id: '1' }, { include: ['pets', 'friends'] });
const data = await store.request(options);
Supplying Options to Modify the Request Behavior
The following options are supported:
host
- The host to use for the request, defaults to thehost
configured withsetBuildURLConfig
.namespace
- The namespace to use for the request, defaults to thenamespace
configured withsetBuildURLConfig
.resourcePath
- The resource path to use for the request, defaults to pluralizing and underscoring the supplied typereload
- Whether to forcibly reload the request if it is already in the store, not supplying this option will delegate to the store's CachePolicy, defaulting tofalse
if none is configured.backgroundReload
- Whether to reload the request if it is already in the store, but to also resolve the promise with the cached value, not supplying this option will delegate to the store's CachePolicy, defaulting tofalse
if none is configured.urlParamsSetting
- an object containing options for how to serialize the query params (seebuildQueryParams
)
import { findRecord } from '@ember-data/active-record/request';
const options = findRecord('person', '1', { include: ['pets', 'friends'] }, { namespace: 'api/v2' });
const data = await store.request(options);
Parameters
type
string
id
string