Class IdentifierCache
publicEach instance of {Store} receives a unique instance of a IdentifierCache.
This cache is responsible for assigning or retrieving the unique identify for arbitrary resource data encountered by the store. Data representing a unique resource or record should always be represented by the same identifier.
It can be configured by consuming applications.
createIdentifierForNewRecord (data) StableRecordIdentifier public
Defined in ../store/addon/-private/identifiers/cache.ts:293
- data
- returns
- StableRecordIdentifier
Returns a new Identifier for the supplied data. Call this method to generate
an identifier when a new resource is being created local to the client and
potentially does not have an id
.
Delegates generation to the user supplied GenerateMethod
if one has been provided
with the signature generateMethod({ type }, 'record')
.
forgetRecordIdentifier (identifierObject) public
Defined in ../store/addon/-private/identifiers/cache.ts:419
- identifierObject
Provides the opportunity to eliminate an identifier from secondary lookup tables as well as eliminates it from ember-data's own lookup tables and book keeping.
Useful when a record has been deleted and the deletion has been persisted and
we do not care about the record anymore. Especially useful when an id
of a
deleted record might be reused later for a new record.
getOrCreateRecordIdentifier (resource) StableRecordIdentifier public
Defined in ../store/addon/-private/identifiers/cache.ts:274
- resource
- returns
- StableRecordIdentifier
Returns the Identifier for the given Resource, creates one if it does not yet exist.
Specifically this means that we:
- validate the
id
type
andlid
combo against known identifiers - return an object with an
lid
that is stable (repeated calls with the sameid
+type
orlid
will return the samelid
value) - this referential stability of the object itself is guaranteed
updateRecordIdentifier (identifierObject, data) StableRecordIdentifier public
Defined in ../store/addon/-private/identifiers/cache.ts:328
- identifierObject
- data
- returns
- StableRecordIdentifier
Provides the opportunity to update secondary lookup tables for existing identifiers
Called after an identifier created with createIdentifierForNewRecord
has been
committed.
Assigned id
to an Identifier
if id
has not previously existed; however,
attempting to change the id
or calling update without providing an id
when
one is missing will throw an error.
sets
id
(ifid
was previouslynull
)lid
andtype
MUST NOT be altered post creationIf a merge occurs, it is possible the returned identifier does not match the originally provided identifier. In this case the abandoned identifier will go through the usual
forgetRecordIdentifier
codepaths.