Skip to main content

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

NameTypeDescription
cb?StandardErrorCallback<void>The callback to be invoked after the method completes successfully.

Returns

StandardPromise<void>


deleteInner

deleteInner(...args): void

deprecated

Parameters

NameType
...argsany[]

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

NameType
Tany

Parameters

NameTypeDescription
paramsObject
params.keystringThe key to get from storage.
params.topicstringThe 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

NameType
Tany

Parameters

NameTypeDescription
paramsObject
params.keystringThe key to get from storage.
params.topicstringThe topic that the data is saved under.
cb?StandardErrorCallback<T>Callback to be called on success.

Returns

StandardPromise<T>


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

NameTypeDescription
paramsObject
params.keyPrefix?stringFilter all keys that don't start with this prefix.
params.topicstringTopic 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

NameTypeDescription
paramsObject
params.keystringThe key to get from storage.
params.topicstringThe 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

NameTypeDescription
paramsComponentMutateParams
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

NameTypeDescription
paramsObject
params.userstringA unique key to store user data under
cb?StandardErrorCallback<void>Callback to be called on success.

Returns

StandardPromise<void>