Documentation / @ember-data/legacy-compat / builders / findRecord
Call Signature
function findRecord<T>(
type,
id,
options?): FindRecordRequestInput<TypeFromInstance<T>, T>;
Defined in: builders/find-record.ts:57
This function builds a request config to find the record for a given identifier or type and id combination. When passed to store.request
, this config will result in the same behavior as a store.findRecord
request. Additionally, it takes the same options as store.findRecord
, with the exception of preload
(which is unsupported).
Example 1
import { findRecord } from '@ember-data/legacy-compat/builders';
const { content: post } = await store.request<Post>(findRecord<Post>('post', '1'));
Example 2
findRecord
can be called with a single identifier argument instead of the combination of type
(modelName) and id
as separate arguments. You may recognize this combo as the typical pairing from JSON:API
import { findRecord } from '@ember-data/legacy-compat/builders';
const { content: post } = await store.request<Post>(findRecord<Post>({ type: 'post', id }));
All @ember-data/legacy-compat
builders exist to enable you to migrate your codebase to using the correct syntax for store.request
while temporarily preserving legacy behaviors. This is useful for quickly upgrading an entire app to a unified syntax while a longer incremental migration is made to shift off of adapters and serializers. To that end, these builders are deprecated and will be removed in a future version of Ember Data.
Type Parameters
T
T
extends TypedRecordInstance
Parameters
type
id
string
optional object with options for the request only if the first param is a ResourceIdentifier, else the string id of the record to be retrieved
options?
FindRecordBuilderOptions
if the first param is a string this will be the optional options for the request. See examples for available options.
Returns
FindRecordRequestInput
<TypeFromInstance
<T
>, T
>
request config
Deprecated
Call Signature
function findRecord(
type,
id,
options?): FindRecordRequestInput;
Defined in: builders/find-record.ts:62
This function builds a request config to find the record for a given identifier or type and id combination. When passed to store.request
, this config will result in the same behavior as a store.findRecord
request. Additionally, it takes the same options as store.findRecord
, with the exception of preload
(which is unsupported).
Example 1
import { findRecord } from '@ember-data/legacy-compat/builders';
const { content: post } = await store.request<Post>(findRecord<Post>('post', '1'));
Example 2
findRecord
can be called with a single identifier argument instead of the combination of type
(modelName) and id
as separate arguments. You may recognize this combo as the typical pairing from JSON:API
import { findRecord } from '@ember-data/legacy-compat/builders';
const { content: post } = await store.request<Post>(findRecord<Post>({ type: 'post', id }));
All @ember-data/legacy-compat
builders exist to enable you to migrate your codebase to using the correct syntax for store.request
while temporarily preserving legacy behaviors. This is useful for quickly upgrading an entire app to a unified syntax while a longer incremental migration is made to shift off of adapters and serializers. To that end, these builders are deprecated and will be removed in a future version of Ember Data.
Parameters
type
string
id
string
optional object with options for the request only if the first param is a ResourceIdentifier, else the string id of the record to be retrieved
options?
FindRecordBuilderOptions
if the first param is a string this will be the optional options for the request. See examples for available options.
Returns
FindRecordRequestInput
request config
Deprecated
Call Signature
function findRecord<T>(resource, options?): FindRecordRequestInput<TypeFromInstance<T>, T>;
Defined in: builders/find-record.ts:63
This function builds a request config to find the record for a given identifier or type and id combination. When passed to store.request
, this config will result in the same behavior as a store.findRecord
request. Additionally, it takes the same options as store.findRecord
, with the exception of preload
(which is unsupported).
Example 1
import { findRecord } from '@ember-data/legacy-compat/builders';
const { content: post } = await store.request<Post>(findRecord<Post>('post', '1'));
Example 2
findRecord
can be called with a single identifier argument instead of the combination of type
(modelName) and id
as separate arguments. You may recognize this combo as the typical pairing from JSON:API
import { findRecord } from '@ember-data/legacy-compat/builders';
const { content: post } = await store.request<Post>(findRecord<Post>({ type: 'post', id }));
All @ember-data/legacy-compat
builders exist to enable you to migrate your codebase to using the correct syntax for store.request
while temporarily preserving legacy behaviors. This is useful for quickly upgrading an entire app to a unified syntax while a longer incremental migration is made to shift off of adapters and serializers. To that end, these builders are deprecated and will be removed in a future version of Ember Data.
Type Parameters
T
T
extends TypedRecordInstance
Parameters
resource
ResourceIdentifierObject
<TypeFromInstance
<T
>>
either a string representing the name of the resource or a ResourceIdentifier object containing both the type (a string) and the id (a string) for the record or an lid (a string) of an existing record
options?
FindRecordBuilderOptions
if the first param is a string this will be the optional options for the request. See examples for available options.
Returns
FindRecordRequestInput
<TypeFromInstance
<T
>, T
>
request config
Deprecated
Call Signature
function findRecord(resource, options?): FindRecordRequestInput;
Defined in: builders/find-record.ts:67
This function builds a request config to find the record for a given identifier or type and id combination. When passed to store.request
, this config will result in the same behavior as a store.findRecord
request. Additionally, it takes the same options as store.findRecord
, with the exception of preload
(which is unsupported).
Example 1
import { findRecord } from '@ember-data/legacy-compat/builders';
const { content: post } = await store.request<Post>(findRecord<Post>('post', '1'));
Example 2
findRecord
can be called with a single identifier argument instead of the combination of type
(modelName) and id
as separate arguments. You may recognize this combo as the typical pairing from JSON:API
import { findRecord } from '@ember-data/legacy-compat/builders';
const { content: post } = await store.request<Post>(findRecord<Post>({ type: 'post', id }));
All @ember-data/legacy-compat
builders exist to enable you to migrate your codebase to using the correct syntax for store.request
while temporarily preserving legacy behaviors. This is useful for quickly upgrading an entire app to a unified syntax while a longer incremental migration is made to shift off of adapters and serializers. To that end, these builders are deprecated and will be removed in a future version of Ember Data.
Parameters
resource
either a string representing the name of the resource or a ResourceIdentifier object containing both the type (a string) and the id (a string) for the record or an lid (a string) of an existing record
options?
FindRecordBuilderOptions
if the first param is a string this will be the optional options for the request. See examples for available options.
Returns
FindRecordRequestInput
request config