Skip to main content
Version: 0.17

Class: IndexedDBCache<QO, TO, QB, TB, QRD, TRD>

A cache used to access records in an IndexedDB database.

Because IndexedDB access is async, this cache extends AsyncRecordCache.

Type parameters​

NameType
QOextends RequestOptions = RecordCacheQueryOptions
TOextends RequestOptions = RecordCacheTransformOptions
QBRecordQueryBuilder
TBRecordTransformBuilder
QRDunknown
TRDextends RecordCacheUpdateDetails = RecordCacheUpdateDetails

Hierarchy​

  • AsyncRecordCache<QO, TO, QB, TB, QRD, TRD>

    ↳ IndexedDBCache

Constructors​

constructor​

• new IndexedDBCache<QO, TO, QB, TB, QRD, TRD>(settings)

Type parameters​

NameType
QOextends RequestOptions = RecordCacheQueryOptions
TOextends RequestOptions = RecordCacheTransformOptions
QBRecordQueryBuilder<string, RecordIdentity>
TBRecordTransformBuilder<string, RecordIdentity, UninitializedRecord>
QRDunknown
TRDextends RecordCacheUpdateDetails = RecordCacheUpdateDetails

Parameters​

NameType
settingsIndexedDBCacheSettings<QO, TO, QB, TB>

Overrides​

AsyncRecordCache<QO, TO, QB, TB, QRD, TRD\>.constructor

Defined in​

indexeddb/src/indexeddb-cache.ts:81

Accessors​

dbName​

• get dbName(): string

IndexedDB database name.

Defaults to the namespace of the app, which can be overridden in the constructor.

Returns​

string

Defined in​

indexeddb/src/indexeddb-cache.ts:133


dbVersion​

• get dbVersion(): number

The version to specify when opening the IndexedDB database.

Returns​

number

Defined in​

indexeddb/src/indexeddb-cache.ts:124


defaultQueryOptions​

• get defaultQueryOptions(): undefined | DefaultRequestOptions<QueryOptions>

Returns​

undefined | DefaultRequestOptions<QueryOptions>

Inherited from​

AsyncRecordCache.defaultQueryOptions

Defined in​

record-cache/dist/modules/record-cache.d.ts:53

• set defaultQueryOptions(options): void

Parameters​

NameType
optionsundefined | DefaultRequestOptions<QueryOptions>

Returns​

void

Inherited from​

AsyncRecordCache.defaultQueryOptions

Defined in​

record-cache/dist/modules/record-cache.d.ts:54


defaultTransformOptions​

• get defaultTransformOptions(): undefined | DefaultRequestOptions<TransformOptions>

Returns​

undefined | DefaultRequestOptions<TransformOptions>

Inherited from​

AsyncRecordCache.defaultTransformOptions

Defined in​

record-cache/dist/modules/record-cache.d.ts:55

• set defaultTransformOptions(options): void

Parameters​

NameType
optionsundefined | DefaultRequestOptions<TransformOptions>

Returns​

void

Inherited from​

AsyncRecordCache.defaultTransformOptions

Defined in​

record-cache/dist/modules/record-cache.d.ts:56


isDBOpen​

• get isDBOpen(): boolean

Returns​

boolean

Defined in​

indexeddb/src/indexeddb-cache.ts:137


keyMap​

• get keyMap(): undefined | RecordKeyMap

Returns​

undefined | RecordKeyMap

Inherited from​

AsyncRecordCache.keyMap

Defined in​

record-cache/dist/modules/record-cache.d.ts:49


name​

• get name(): undefined | string

Returns​

undefined | string

Inherited from​

AsyncRecordCache.name

Defined in​

record-cache/dist/modules/record-cache.d.ts:47


namespace​

• get namespace(): string

Returns​

string

Defined in​

indexeddb/src/indexeddb-cache.ts:101


processors​

• get processors(): AsyncOperationProcessor[]

Returns​

AsyncOperationProcessor[]

Inherited from​

AsyncRecordCache.processors

Defined in​

record-cache/dist/modules/async-record-cache.d.ts:29


queryBuilder​

• get queryBuilder(): QueryBuilder

Returns​

QueryBuilder

Inherited from​

AsyncRecordCache.queryBuilder

Defined in​

record-cache/dist/modules/record-cache.d.ts:51


schema​

• get schema(): RecordSchema

Returns​

RecordSchema

Inherited from​

AsyncRecordCache.schema

Defined in​

record-cache/dist/modules/record-cache.d.ts:48


transformBuilder​

• get transformBuilder(): TransformBuilder

Returns​

TransformBuilder

Inherited from​

AsyncRecordCache.transformBuilder

Defined in​

record-cache/dist/modules/record-cache.d.ts:52


validatorFor​

• get validatorFor(): undefined | ValidatorForFn<StandardValidator | StandardRecordValidator>

Returns​

undefined | ValidatorForFn<StandardValidator | StandardRecordValidator>

Inherited from​

AsyncRecordCache.validatorFor

Defined in​

record-cache/dist/modules/record-cache.d.ts:50

Methods​

addInverseRelationshipsAsync​

â–¸ addInverseRelationshipsAsync(relationships): Promise<void>

Parameters​

NameType
relationshipsRecordRelationshipIdentity[]

Returns​

Promise<void>

Overrides​

AsyncRecordCache.addInverseRelationshipsAsync

Defined in​

indexeddb/src/indexeddb-cache.ts:537


applyRecordChangesetAsync​

â–¸ applyRecordChangesetAsync(changeset): Promise<void>

Parameters​

NameType
changesetRecordChangeset

Returns​

Promise<void>

Inherited from​

AsyncRecordCache.applyRecordChangesetAsync

Defined in​

record-cache/dist/modules/async-record-cache.d.ts:42


clearRecords​

â–¸ clearRecords(type): Promise<void>

Parameters​

NameType
typestring

Returns​

Promise<void>

Defined in​

indexeddb/src/indexeddb-cache.ts:273


closeDB​

â–¸ closeDB(): Promise<void>

Returns​

Promise<void>

Defined in​

indexeddb/src/indexeddb-cache.ts:170


createDB​

â–¸ createDB(db): void

Initializes the contents of the database.

Idempotently register models which do not yet have corresponding object stores. Also, creates an object store for tracking inverse relationships, if it is missing.

Override this method and/or registerModel to provide more advanced db initialization.

Parameters​

NameType
dbIDBDatabase

Returns​

void

Defined in​

indexeddb/src/indexeddb-cache.ts:199


createInverseRelationshipStore​

â–¸ createInverseRelationshipStore(db): void

Parameters​

NameType
dbIDBDatabase

Returns​

void

Defined in​

indexeddb/src/indexeddb-cache.ts:213


createTransaction​

â–¸ createTransaction(storeNames, mode?): IDBTransaction

Parameters​

NameType
storeNamesstring[]
mode?IDBTransactionMode

Returns​

IDBTransaction

Defined in​

indexeddb/src/indexeddb-cache.ts:258


deleteDB​

â–¸ deleteDB(): Promise<void>

Returns​

Promise<void>

Defined in​

indexeddb/src/indexeddb-cache.ts:242


emit​

â–¸ emit(event, ...args): void

Parameters​

NameType
eventEvent
...argsunknown[]

Returns​

void

Inherited from​

AsyncRecordCache.emit

Defined in​

core/dist/modules/evented.d.ts:23


getInverseRelationshipsAsync​

â–¸ getInverseRelationshipsAsync(recordIdentityOrIdentities): Promise<RecordRelationshipIdentity[]>

Parameters​

NameType
recordIdentityOrIdentitiesRecordIdentity | RecordIdentity[]

Returns​

Promise<RecordRelationshipIdentity[]>

Overrides​

AsyncRecordCache.getInverseRelationshipsAsync

Defined in​

indexeddb/src/indexeddb-cache.ts:478


getInverseTransformOperator​

â–¸ getInverseTransformOperator(op): AsyncInverseTransformOperator

Parameters​

NameType
opstring

Returns​

AsyncInverseTransformOperator

Inherited from​

AsyncRecordCache.getInverseTransformOperator

Defined in​

record-cache/dist/modules/async-record-cache.d.ts:32


getQueryOperator​

â–¸ getQueryOperator(op): AsyncQueryOperator

Parameters​

NameType
opstring

Returns​

AsyncQueryOperator

Inherited from​

AsyncRecordCache.getQueryOperator

Defined in​

record-cache/dist/modules/async-record-cache.d.ts:30


getQueryOptions​

â–¸ getQueryOptions(query, expression?): undefined | QO

Parameters​

NameType
queryRecordQuery
expression?RecordQueryExpression

Returns​

undefined | QO

Inherited from​

AsyncRecordCache.getQueryOptions

Defined in​

record-cache/dist/modules/record-cache.d.ts:57


getRecordAsync​

â–¸ getRecordAsync(record): Promise<undefined | InitializedRecord>

Parameters​

NameType
recordRecordIdentity

Returns​

Promise<undefined | InitializedRecord>

Overrides​

AsyncRecordCache.getRecordAsync

Defined in​

indexeddb/src/indexeddb-cache.ts:289


getRecordsAsync​

â–¸ getRecordsAsync(typeOrIdentities?): Promise<InitializedRecord[]>

Parameters​

NameType
typeOrIdentities?string | RecordIdentity[]

Returns​

Promise<InitializedRecord[]>

Overrides​

AsyncRecordCache.getRecordsAsync

Defined in​

indexeddb/src/indexeddb-cache.ts:313


getRelatedRecordAsync​

â–¸ getRelatedRecordAsync(identity, relationship): Promise<undefined | null | RecordIdentity>

Parameters​

NameType
identityRecordIdentity
relationshipstring

Returns​

Promise<undefined | null | RecordIdentity>

Inherited from​

AsyncRecordCache.getRelatedRecordAsync

Defined in​

record-cache/dist/modules/async-record-cache.d.ts:43


getRelatedRecordsAsync​

â–¸ getRelatedRecordsAsync(identity, relationship): Promise<undefined | RecordIdentity[]>

Parameters​

NameType
identityRecordIdentity
relationshipstring

Returns​

Promise<undefined | RecordIdentity[]>

Inherited from​

AsyncRecordCache.getRelatedRecordsAsync

Defined in​

record-cache/dist/modules/async-record-cache.d.ts:44


getTransformOperator​

â–¸ getTransformOperator(op): AsyncTransformOperator

Parameters​

NameType
opstring

Returns​

AsyncTransformOperator

Inherited from​

AsyncRecordCache.getTransformOperator

Defined in​

record-cache/dist/modules/async-record-cache.d.ts:31


getTransformOptions​

â–¸ getTransformOptions(transform, operation?): undefined | TO

Parameters​

NameType
transformRecordTransform
operation?RecordOperation

Returns​

undefined | TO

Inherited from​

AsyncRecordCache.getTransformOptions

Defined in​

record-cache/dist/modules/record-cache.d.ts:58


listeners​

â–¸ listeners(event): Listener[]

Parameters​

NameType
eventEvent

Returns​

Listener[]

Inherited from​

AsyncRecordCache.listeners

Defined in​

core/dist/modules/evented.d.ts:24


liveQuery​

â–¸ liveQuery(queryOrExpressions, options?, id?): AsyncLiveQuery<QO, TO, QB, TB>

Parameters​

NameType
queryOrExpressionsQueryOrExpressions<RecordQueryExpression, QB>
options?DefaultRequestOptions<QO>
id?string

Returns​

AsyncLiveQuery<QO, TO, QB, TB>

Inherited from​

AsyncRecordCache.liveQuery

Defined in​

record-cache/dist/modules/async-record-cache.d.ts:61


migrateDB​

â–¸ migrateDB(db, event): void

Migrates the database to align with an updated schema.

By default, this will attempt a naive migration by invoking createDB, which idempotently creates object stores as needed.

Override this method to provide more sophisticated migrations.

Parameters​

NameType
dbIDBDatabase
eventIDBVersionChangeEvent

Returns​

void

Defined in​

indexeddb/src/indexeddb-cache.ts:231


off​

â–¸ off(event, listener?): void

Parameters​

NameType
eventEvent
listener?Listener

Returns​

void

Inherited from​

AsyncRecordCache.off

Defined in​

core/dist/modules/evented.d.ts:21


on​

â–¸ on(event, listener): () => void

Parameters​

NameType
eventEvent
listenerListener

Returns​

fn

â–¸ (): void

Returns​

void

Inherited from​

AsyncRecordCache.on

Defined in​

core/dist/modules/evented.d.ts:20


one​

â–¸ one(event, listener): () => void

Parameters​

NameType
eventEvent
listenerListener

Returns​

fn

â–¸ (): void

Returns​

void

Inherited from​

AsyncRecordCache.one

Defined in​

core/dist/modules/evented.d.ts:22


openDB​

â–¸ openDB(): Promise<IDBDatabase>

Returns​

Promise<IDBDatabase>

Defined in​

indexeddb/src/indexeddb-cache.ts:141


patch​

â–¸ patch(operationOrOperations): Promise<PatchResult>

Patches the cache with an operation or operations.

deprecated since v0.17

Parameters​

NameType
operationOrOperationsRecordOperation | RecordOperation[] | RecordTransformBuilderFunc | RecordOperationTerm<string, RecordIdentity, UninitializedRecord> | RecordOperationTerm<string, RecordIdentity, UninitializedRecord>[]

Returns​

Promise<PatchResult>

Inherited from​

AsyncRecordCache.patch

Defined in​

record-cache/dist/modules/async-record-cache.d.ts:60


query​

â–¸ query<RequestData>(queryOrExpressions, options?, id?): Promise<RequestData>

Queries the cache.

Type parameters​

NameType
RequestDataextends RecordQueryResult<InitializedRecord> = RecordQueryResult<InitializedRecord>

Parameters​

NameType
queryOrExpressionsQueryOrExpressions<RecordQueryExpression, QB>
options?DefaultRequestOptions<QO>
id?string

Returns​

Promise<RequestData>

Inherited from​

AsyncRecordCache.query

Defined in​

record-cache/dist/modules/async-record-cache.d.ts:48

â–¸ query<RequestData>(queryOrExpressions, options, id?): Promise<FullResponse<RequestData, QRD, RecordOperation>>

Type parameters​

NameType
RequestDataextends RecordQueryResult<InitializedRecord> = RecordQueryResult<InitializedRecord>

Parameters​

NameType
queryOrExpressionsQueryOrExpressions<RecordQueryExpression, QB>
optionsFullRequestOptions<QO>
id?string

Returns​

Promise<FullResponse<RequestData, QRD, RecordOperation>>

Inherited from​

AsyncRecordCache.query

Defined in​

record-cache/dist/modules/async-record-cache.d.ts:49


registerModel​

â–¸ registerModel(db, type): void

Parameters​

NameType
dbIDBDatabase
typestring

Returns​

void

Defined in​

indexeddb/src/indexeddb-cache.ts:267


removeInverseRelationshipsAsync​

â–¸ removeInverseRelationshipsAsync(relationships): Promise<void>

Parameters​

NameType
relationshipsRecordRelationshipIdentity[]

Returns​

Promise<void>

Overrides​

AsyncRecordCache.removeInverseRelationshipsAsync

Defined in​

indexeddb/src/indexeddb-cache.ts:565


removeRecordAsync​

â–¸ removeRecordAsync(recordIdentity): Promise<undefined | InitializedRecord>

Parameters​

NameType
recordIdentityRecordIdentity

Returns​

Promise<undefined | InitializedRecord>

Overrides​

AsyncRecordCache.removeRecordAsync

Defined in​

indexeddb/src/indexeddb-cache.ts:433


removeRecordsAsync​

â–¸ removeRecordsAsync(records): Promise<InitializedRecord[]>

Parameters​

NameType
recordsRecordIdentity[]

Returns​

Promise<InitializedRecord[]>

Overrides​

AsyncRecordCache.removeRecordsAsync

Defined in​

indexeddb/src/indexeddb-cache.ts:449


reopenDB​

â–¸ reopenDB(): Promise<IDBDatabase>

Returns​

Promise<IDBDatabase>

Defined in​

indexeddb/src/indexeddb-cache.ts:184


reset​

â–¸ reset(): Promise<void>

Returns​

Promise<void>

Defined in​

indexeddb/src/indexeddb-cache.ts:113


setRecordAsync​

â–¸ setRecordAsync(record): Promise<void>

Parameters​

NameType
recordInitializedRecord

Returns​

Promise<void>

Overrides​

AsyncRecordCache.setRecordAsync

Defined in​

indexeddb/src/indexeddb-cache.ts:382


setRecordsAsync​

â–¸ setRecordsAsync(records): Promise<void>

Parameters​

NameType
recordsInitializedRecord[]

Returns​

Promise<void>

Overrides​

AsyncRecordCache.setRecordsAsync

Defined in​

indexeddb/src/indexeddb-cache.ts:398


update​

â–¸ update<RequestData>(transformOrOperations, options?, id?): Promise<RequestData>

Updates the cache.

Type parameters​

NameType
RequestDataextends RecordTransformResult<InitializedRecord> = RecordTransformResult<InitializedRecord>

Parameters​

NameType
transformOrOperationsTransformOrOperations<RecordOperation, TB>
options?DefaultRequestOptions<TO>
id?string

Returns​

Promise<RequestData>

Inherited from​

AsyncRecordCache.update

Defined in​

record-cache/dist/modules/async-record-cache.d.ts:53

â–¸ update<RequestData>(transformOrOperations, options, id?): Promise<FullResponse<RequestData, TRD, RecordOperation>>

Type parameters​

NameType
RequestDataextends RecordTransformResult<InitializedRecord> = RecordTransformResult<InitializedRecord>

Parameters​

NameType
transformOrOperationsTransformOrOperations<RecordOperation, TB>
optionsFullRequestOptions<TO>
id?string

Returns​

Promise<FullResponse<RequestData, TRD, RecordOperation>>

Inherited from​

AsyncRecordCache.update

Defined in​

record-cache/dist/modules/async-record-cache.d.ts:54


upgrade​

â–¸ upgrade(): Promise<void>

Returns​

Promise<void>

Defined in​

indexeddb/src/indexeddb-cache.ts:105