Class RecordDataManager

public

The RecordDataManager wraps a RecordData cache enforcing that only the public API surface area is exposed.

This class is the the return value of both the recordDataFor function supplied to the store hook instantiateRecord, and the recordDataFor method on the RecordDataStoreWrapper. It is not directly instantiatable.

It handles translating between cache versions when necessary, for instance when a Store is configured to use both a v1 and a v2 cache depending on some heuristic.

Starting with the v2 spec, the cache is designed such that it may be implemented as a singleton. However, because the v1 spec was not designed for this whenever we encounter any v1 cache we must wrap all caches, even singletons, in non-singleton managers to preserve v1 compatibility.

To avoid this performance penalty being paid by all applications, singleton behavior may be opted-in via the configuration supplied to your Ember application at build time. This effectively removes support for v1 caches.

1
2
3
4
5
let app = new EmberApp(defaults, {
  emberData: {
    useSingletonManager: true
  },
});

Show:

identifier
options

[LIFECYLCE] Signal to the cache that a new record has been instantiated on the client

It returns properties from options that should be set on the record during the create process. This return value behavior is deprecated.

identifier
errors

[LIFECYCLE] Signals to the cache that a resource was update via a save transaction failed.

identifier
data

[LIFECYCLE] Signals to the cache that a resource was successfully updated as part of a save transaction.

identifier
propertyName
returns
Unknown

Retrieve the data for an attribute from the cache

identifier
returns

Query the cache for any validation errors applicable to the given resource.

identifier
propertyName
returns
resource relationship object

Query the cache for the current state of a relationship property

identifier
returns
Boolean

Query the cache for whether any mutated attributes exist

identifier
returns
Boolean

Query the cache for whether a given resource is marked as deleted (but not necessarily persisted yet).

identifier
returns
Boolean

Query the cache for whether a given resource has been deleted and that deletion has also been persisted.

identifier
returns
Boolean

Query the cache for whether a given resource has any available data

identifier
returns
Boolean

Query the cache for whether a given resource was created locally and not yet persisted.

identifier
data
hasRecord
returns
Void | string[]
if `hasRecord` is true then calculated key changes should be returned

Push resource data from a remote source into the cache for this identifier

identifier
returns
the names of attributes that were restored

Tell the cache to discard any uncommitted mutations to attributes

identifier
propertyName
value

Mutate the data for an attribute in the cache

identifier
isDeleted

Update the cache state for the given resource to be marked as locally deleted, or remove such a mark.

op
the operation to perform
returns
Void

Perform an operation on the cache to update the remote state.

Note: currently the only valid operation is a MergeOperation which occurs when a collision of identifiers is detected.

identifier

[LIFECYCLE] Signals to the cache that all data for a resource should be cleared.

operation

Update resource data with a local mutation. Currently supports operations on relationships only.

identifier

[LIFECYCLE] Signals to the cache that a resource will be part of a save transaction.