Finsemble: Storing Data

Storing Data

The StorageClient and StorageService provide an interface for the different storage options provided. The StorageService provides a centralized location to handle retrieving and transmitting your application data. You are not limited to just one method of storage. By default, local storage is used; however, you can pass astorageType in your params object as long as the model has been loaded into the storage service (e.g., params.storageType = 'redis').

Currently, only local storage is provided out of the box. A Redis example is coming soon. There is currently no way to add additional models outside of the core Finsemble Library. This will be addressed shortly after Beta.

Each storage model inherits the base storage model.

var BaseStorage = require('./base');
var TestModel = function () {
    BaseStorage.call(this, arguments);

    this.save = function (params, cb) {

    };

    this.get = function (params, cb) {

    };

    this.delete = function (params, cb) {

    };

    this.clear = function (params,cb) {

    };

    this.getMultiple = function (params,cb) {

    };
};

TestModel.prototype = new BaseStorage();
module.exports = TestModel;

There are 5 basic features to base storage. They are as follows:

  1. Save Save a key value pair. The value can be anything you want. For local storage, it gets stringified before it gets stored.
  2. Get Get a value by key. This returns a string of the item that was stored.
  3. Delete Delete a value by key.
  4. GetMultiple Coming Soon.
  5. Clear Coming Soon.

Examples

    FSBL.clients.StorageClient.save(
        {
            key:"newKey",
            value:{
                a:"a",
                b:"b"
            }
        }, function(err, response){

        })
    FSBL.clients.StorageClient.get(
        {
            key:"newKey"
        }, function(err, response){

        })
    FSBL.clients.StorageClient.delete(
        {
            key:"newKey"
        }, function(err, response){

        })