Store
Defined in: store/Store.ts:40
A class representing a store of data, with multiple storage adapters.
Implements
Section titled “Implements”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new Store():
Store
Returns
Section titled “Returns”Store
Methods
Section titled “Methods”destroy()
Section titled “destroy()”destroy():
void
Defined in: store/Store.ts:85
Destroys the store and all its adapters.
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”getAdapter()
Section titled “getAdapter()”getAdapter<
T
>(adapterId
):T
Defined in: store/Store.ts:65
Retrieves a registered storage adapter.
Type Parameters
Section titled “Type Parameters”T
extends IStorageAdapter
= IStorageAdapter
The type of the adapter.
Parameters
Section titled “Parameters”adapterId
Section titled “adapterId”string
The ID of the adapter.
Returns
Section titled “Returns”T
The adapter.
Implementation of
Section titled “Implementation of”hasAdapter()
Section titled “hasAdapter()”hasAdapter(
adapterId
):boolean
Defined in: store/Store.ts:78
Checks if a storage adapter is registered.
Parameters
Section titled “Parameters”adapterId
Section titled “adapterId”string
The ID of the adapter.
Returns
Section titled “Returns”boolean
True if the adapter is registered, false otherwise.
Implementation of
Section titled “Implementation of”initialize()
Section titled “initialize()”initialize(
app
):IStore
Defined in: store/Store.ts:160
Parameters
Section titled “Parameters”Returns
Section titled “Returns”Implementation of
Section titled “Implementation of”load()
Section titled “load()”load(
adapterId
,key
):Promise
<any
>
Defined in: store/Store.ts:152
Loads data from a storage adapter.
Parameters
Section titled “Parameters”adapterId
Section titled “adapterId”string
The ID of the adapter.
string
The key to load the data from.
Returns
Section titled “Returns”Promise
<any
>
A promise that resolves with the loaded data.
Implementation of
Section titled “Implementation of”registerAdapter()
Section titled “registerAdapter()”registerAdapter(
adapter
,adapterOptions
):Promise
<void
>
Defined in: store/Store.ts:50
Registers a new storage adapter with the store.
Parameters
Section titled “Parameters”adapter
Section titled “adapter”The adapter to register.
adapterOptions
Section titled “adapterOptions”any
The options to initialize the adapter with.
Returns
Section titled “Returns”Promise
<void
>
A promise that resolves when the adapter has been registered and initialized.
Implementation of
Section titled “Implementation of”save()
Section titled “save()”save(
adapterId
,key
,data
,awaitSave?
):Promise
<any
>
Defined in: store/Store.ts:100
Saves data with a storage adapter.
Parameters
Section titled “Parameters”adapterId
Section titled “adapterId”The ID of the adapter, or an array of IDs, or an array of save configurations.
string
| string
[] | Partial
<AdapterSaveConfig
> | Partial
<AdapterSaveConfig
>[]
string
The key to save the data under.
any
The data to save.
awaitSave?
Section titled “awaitSave?”boolean
= true
Whether to wait for the save operation to complete before returning.
Returns
Section titled “Returns”Promise
<any
>
A promise that resolves with the result of the save operation.