Skip to content

Store

Defined in: store/Store.ts:40

A class representing a store of data, with multiple storage adapters.

Implements

Constructors

new Store()

new Store(): Store

Returns

Store

Methods

destroy()

destroy(): void

Defined in: store/Store.ts:85

Destroys the store and all its adapters.

Returns

void

Implementation of

IStore.destroy


getAdapter()

getAdapter<T>(adapterId): T

Defined in: store/Store.ts:65

Retrieves a registered storage adapter.

Type Parameters

T extends IStorageAdapter = IStorageAdapter

The type of the adapter.

Parameters

adapterId

string

The ID of the adapter.

Returns

T

The adapter.

Implementation of

IStore.getAdapter


hasAdapter()

hasAdapter(adapterId): boolean

Defined in: store/Store.ts:78

Checks if a storage adapter is registered.

Parameters

adapterId

string

The ID of the adapter.

Returns

boolean

True if the adapter is registered, false otherwise.

Implementation of

IStore.hasAdapter


initialize()

initialize(app): IStore

Defined in: store/Store.ts:160

Parameters

app

IApplication

Returns

IStore

Implementation of

IStore.initialize


load()

load(adapterId, key): Promise<any>

Defined in: store/Store.ts:152

Loads data from a storage adapter.

Parameters

adapterId

string

The ID of the adapter.

key

string

The key to load the data from.

Returns

Promise<any>

A promise that resolves with the loaded data.

Implementation of

IStore.load


registerAdapter()

registerAdapter(adapter, adapterOptions): Promise<void>

Defined in: store/Store.ts:50

Registers a new storage adapter with the store.

Parameters

adapter

IStorageAdapter

The adapter to register.

adapterOptions

any

The options to initialize the adapter with.

Returns

Promise<void>

A promise that resolves when the adapter has been registered and initialized.

Implementation of

IStore.registerAdapter


save()

save(adapterId, key, data, awaitSave?): Promise<any>

Defined in: store/Store.ts:100

Saves data with a storage adapter.

Parameters

adapterId

The ID of the adapter, or an array of IDs, or an array of save configurations.

string | string[] | Partial<AdapterSaveConfig> | Partial<AdapterSaveConfig>[]

key

string

The key to save the data under.

data

any

The data to save.

awaitSave?

boolean = true

Whether to wait for the save operation to complete before returning.

Returns

Promise<any>

A promise that resolves with the result of the save operation.

Implementation of

IStore.save