Class: StorageClient
Storage Client (Finsemble Connect)
The Storage Client handles saving and retrieving data for your SmartDesktop.
See the Storing Data tutorial for an overview of using the Storage Client.
Methods
-
addEventListener(event, handler)
-
Name Type Description eventstring handlerFunction -
clearCache(cb)
-
Clears a storage adapter of all data.
Name Type Description cbStandardCallback The callback to be invoked if the method fails.
-
get(params, cb)
-
Get a value from storage.
Name Type Description paramsName Type Description keystring The key to get from storage.
topicstring The topic that the data is saved under.
cbStandardCallback The callback to be invoked if the method fails.
Example
FSBL.Clients.StorageClient.get({ topic:"finsemble", key:"testKey" }, function(err, data) { var myData = data; }); -
keys(params, cb)
-
Get all keys for the topic.
Name Type Description paramsName Type Description keyPrefixstring optional Filter all keys that don't start with this prefix.
topicstring Topic for the keys to return.
cbStandardCallback The callback to be invoked if the method fails.
Example
FSBL.Clients.StorageClient.keys({topic:"finsemble", keyPrefix:"test"}, function(err, data){ var myKeys = data; }); -
remove(params, cb)
-
Delete a value from storage.
Name Type Description paramsName Type Description keystring The key to get from storage.
topicstring The topic that the data is saved under.
cbStandardCallback The callback to be invoked if the method fails.
Example
FSBL.Clients.StorageClient.remove({ key:"testKey" }) -
removeEventListener(event, handler)
-
Removes an event listener added by addEventListener
Name Type Description eventany An event that was used with addEventListener to add a listener
handlerany The handler that was used with addEventListener for the event
-
save(params, cb)
-
Save a key value pair into storage.
Name Type Description paramscomponentMutateParams Name Type Description fieldstring optional Field to save.
fieldsoptional Fields to save.
keystring optional Key to store the data under.
stateVaroptional Whether the data is componentState or windowData.
topicstring optional Topic that the data is stored under.
valueany optional Value to save.
cbStandardCallback The callback to be invoked if the method fails.
Example
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 paramsName Type Description dataStorestring optional Identifies the data store (e.g. "localStorage", "redis").
topicstring If specified then data store is set only for topic.
cbStandardCallback The callback to be invoked if the method fails.
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 paramsName Type Description userstring A unique key to store user data under
cbStandardCallback The callback to be invoked if the method fails.
Example
FSBL.Clients.StorageClient.setUser({ user: "JohnDeere"});