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
event string
handler Function

addListener
(event, handler)

Name Type Description
event any
handler any

cleanup
()

clearCache
(cb)

Clears a storage adapter of all data.

Name Type Description
cb StandardCallback

The callback to be invoked if the method fails.

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 StandardCallback

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
params
Name Type Description
keyPrefix string optional

Filter all keys that don't start with this prefix.

topic string

Topic for the keys to return.

cb StandardCallback

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
params
Name Type Description
key string

The key to get from storage.

topic string

The topic that the data is saved under.

cb StandardCallback

The callback to be invoked if the method fails.

Example
FSBL.Clients.StorageClient.remove({ key:"testKey" })

removeEventListener
(event, handler)

Name Type Description
event any
handler any

removeListener
(event, handler)

Name Type Description
event any
handler any

save
(params, cb)

Save a key value pair into storage.

Name Type Description
params componentMutateParams
Name Type Description
field string optional

Field to save.

fields optional

Fields to save.

key string optional

Key to store the data under.

stateVar optional

Whether the data is componentState or windowState.

topic string optional

Topic that the data is stored under.

value any optional

Value to save.

cb StandardCallback

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
params
Name Type Description
dataStore string optional

Identifies the data store (e.g. "localStorage", "redis").

topic string

If specified then data store is set only for topic.

cb StandardCallback

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
params
Name Type Description
user string

A unique key to store user data under

cb StandardCallback

The callback to be invoked if the method fails.

Example
FSBL.Clients.StorageClient.setUser({ user: "JohnDeere"});