Class: StorageClient
Storage Client (Finsemble Connect)
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.
Methods
-
clearCache(cb)
-
Clears a storage adapter of all data.
Name Type Description cb
StandardErrorCallback optional -
get(params, cb)
-
Get a value from storage.
Name Type Description params
Name Type Description key
string The key to get from storage.
topic
string The topic that the data is saved under.
cb
StandardErrorCallback optional Example
FSBL.Clients.StorageClient.get({ topic:"finsemble", key:"testKey" }, function(err, data) { var myData = data; });
-
getStandardized(params, cb)
-
Get a value from storage.
Name Type Description params
Name Type Description key
string The key to get from storage.
topic
string The topic that the data is saved under.
cb
StandardErrorCallback optional Example
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" });
-
keys(params, cb)
-
Get all keys for the topic.
Name Type Description params
Name Type Description keyPrefix
optional Filter all keys that don't start with this prefix.
topic
string Topic for the keys to return.
cb
StandardErrorCallback optional Example
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"});
-
remove(params, cb)
-
Delete a value from storage.
Name Type Description params
Name Type Description key
string The key to get from storage.
topic
string The topic that the data is saved under.
cb
StandardErrorCallback optional Example
FSBL.Clients.StorageClient.remove({ key:"testKey" }) await FSBL.Clients.StorageClient.remove({ key:"testKey" })
-
save(params, cb)
-
Save a key value pair into storage.
Name Type Description params
ComponentMutateParams Name Type Description field
optional Field to save.
fields
optional Fields to save.
key
optional Key to store the data under.
stateVar
optional Whether the data is componentState or windowData. Defaults to "windowData"
topic
optional Topic that the data is stored under.
value
any optional Value to save.
cb
StandardErrorCallback optional Example
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"});
-
setStore(params, cb)
-
Specifies the data store. For normal operation this function doesn't have to be invoked -- the default data store is set in configuration.
Name Type Description params
Name Type Description dataStore
optional Identifies the data store (e.g. "localStorage", "redis").
topic
string If specified then data store is set only for topic.
cb
StandardErrorCallback optional Example
FSBL.Clients.StorageClient.setStore({topic:"finsemble", dataStore:"redis"})
-
setUser(params, cb)
-
Define the user name for storage (i.e., each user has unique storage).
Name Type Description params
Name Type Description user
string A unique key to store user data under
cb
StandardErrorCallback optional Example
FSBL.Clients.StorageClient.setUser({ user: "JohnDeere"});