Module: StorageClient
The Storage Client handles saving and retrieving data for your smart desktop.
See the Storing Data tutorial for an overview of using the Storage Client.
Functions
clearCache
▸ clearCache(cb?
): StandardPromise
<void
>
Clears a storage adapter of all data.
Parameters
Name | Type | Description |
---|---|---|
cb? | StandardErrorCallback <void > | The callback to be invoked after the method completes successfully. |
Returns
StandardPromise
<void
>
deleteInner
▸ deleteInner(...args
): void
deprecated
Parameters
Name | Type |
---|---|
...args | any [] |
Returns
void
get
▸ get<T
>(params
, cb?
): Promise
<T
>
deprecated
Please use getStandardized() for a standardized Promise<{err, data}>
This function returns a Promise<T>
and rejects on an error. This is maintained for backward compatibility.
Get a value from storage.
FSBL.Clients.StorageClient.get({ topic:"finsemble", key:"testKey" }, function(err, data) {
var myData = data;
});
Type parameters
Name | Type |
---|---|
T | any |
Parameters
Name | Type | Description |
---|---|---|
params | Object | |
params.key | string | The key to get from storage. |
params.topic | string | The topic that the data is saved under. |
cb? | StandardErrorCallback <T > | Callback to be called on success. |
Returns
Promise
<T
>
getStandardized
▸ getStandardized<T
>(params
, cb?
): StandardPromise
<T
>
Get a value from storage.
FSBL.Clients.StorageClient.getStandardized({ topic:"finsemble", key:"testKey" }, function(err, data) {
let myData = data;
});
const {err, data} = await FSBL.Clients.StorageClient.getStandardized({ topic:"finsemble", key:"testKey" });
Type parameters
Name | Type |
---|---|
T | any |
Parameters
Name | Type | Description |
---|---|---|
params | Object | |
params.key | string | The key to get from storage. |
params.topic | string | The topic that the data is saved under. |
cb? | StandardErrorCallback <T > | Callback to be called on success. |
Returns
keys
▸ keys(params
, cb?
): StandardPromise
<string
[]>
Get all keys for the topic.
FSBL.Clients.StorageClient.keys({topic:"finsemble", keyPrefix:"test"}, function(err, data){
let myKeys = data;
});
const {err, data} = await FSBL.Clients.StorageClient.keys({topic:"finsemble", keyPrefix:"test"});
Parameters
Name | Type | Description |
---|---|---|
params | Object | |
params.keyPrefix? | string | Filter all keys that don't start with this prefix. |
params.topic | string | Topic for the keys to return. |
cb? | StandardErrorCallback <string []> | Callback to be called on success. |
Returns
StandardPromise
<string
[]>
remove
▸ remove(params
, cb?
): StandardPromise
<void
>
Delete a value from storage.
FSBL.Clients.StorageClient.remove({ key:"testKey" })
await FSBL.Clients.StorageClient.remove({ key:"testKey" })
Parameters
Name | Type | Description |
---|---|---|
params | Object | |
params.key | string | The key to get from storage. |
params.topic | string | The topic that the data is saved under. |
cb? | StandardErrorCallback <void > | Callback to be called on success. |
Returns
StandardPromise
<void
>
save
▸ save(params
, cb?
): StandardPromise
<void
>
Save a key value pair into storage.
FSBL.Clients.StorageClient.save({topic:"finsemble", key:"testKey", value:"testValue"});
FSBL.Clients.StorageClient.save({topic:"finsemble", key:"testKey", value:"testValue"}, (err, data) => {});
const {err, data} = await FSBL.Clients.StorageClient.save({topic:"finsemble", key:"testKey", value:"testValue"});
Parameters
Name | Type | Description |
---|---|---|
params | ComponentMutateParams | |
cb? | StandardErrorCallback <void > | Callback to be called on success. |
Returns
StandardPromise
<void
>
setUser
▸ setUser(params
, cb?
): StandardPromise
<void
>
Define the user name for storage (i.e., each user has unique storage).
FSBL.Clients.StorageClient.setUser({ user: "JohnDeere"});
Parameters
Name | Type | Description |
---|---|---|
params | Object | |
params.user | string | A unique key to store user data under |
cb? | StandardErrorCallback <void > | Callback to be called on success. |
Returns
StandardPromise
<void
>