Skip to content
module@warp-drive/core

Function recordIdentifierFor() ​

ts
function recordIdentifierFor<T extends TypedRecordInstance>(record: T): ResourceKey<TypeFromInstance<T>>;
function recordIdentifierFor(record: unknown): ResourceKey;

Call Signature ​

ts
function recordIdentifierFor<T extends TypedRecordInstance>(record: T): ResourceKey<TypeFromInstance<T>>;

Defined in: warp-drive-packages/core/src/store/-private/caches/instance-cache.ts:54

Retrieves the unique referentially-stable ResourceKey assigned to the given record instance.

js
import { recordIdentifierFor } from "@warp-drive/core";
// ... gain access to a record, for instance with peekRecord or findRecord
const record = store.peekRecord("user", "1");
// get the identifier for the record (see docs for ResourceKey)
const identifier = recordIdentifierFor(record);
// access the identifier's properties.
const { id, type, lid } = identifier;

Type Parameters ​

T ​

T extends TypedRecordInstance

Parameters ​

record ​

T

a record instance previously obstained from the store.

Returns ​

ResourceKey<TypeFromInstance<T>>

Call Signature ​

ts
function recordIdentifierFor(record: unknown): ResourceKey;

Defined in: warp-drive-packages/core/src/store/-private/caches/instance-cache.ts:55

Retrieves the unique referentially-stable ResourceKey assigned to the given record instance.

js
import { recordIdentifierFor } from "@warp-drive/core";
// ... gain access to a record, for instance with peekRecord or findRecord
const record = store.peekRecord("user", "1");
// get the identifier for the record (see docs for ResourceKey)
const identifier = recordIdentifierFor(record);
// access the identifier's properties.
const { id, type, lid } = identifier;

Parameters ​

record ​

unknown

a record instance previously obstained from the store.

Returns ​

ResourceKey

Released under the MIT License.