Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
.gitignore
.npmignore
Readme.md
index.js
package.json

Readme.md

cubby

a cubby that uses mysql (there is also a flat file version)

works well as a simple json datastore

dependency

installation

$ npm install mysql-cubby

usage

var mysql = require('mysql'),
    Cubby = require('mysql-cubby'),
    connection = mysql.createConnection({
        /* connection info*/
    });

connection.connect();

var cubby = new Cubby({connection: connection /*, table: '', name: ''*/});

cubby.load(function () {
    cubby.set('foo', 'bar');
    console.log(cubby.get('foo'));
});

or

cubby.load(function () {
    cubby.set({
        one: 'one',
        two: 'two',
        three: {
            nested: true
        }
    });

    console.log(cubby.get('one')); // returns one
    console.log(cubby.getPath('three.nested')); // returns true
});

multiple cubbies

by default creating a cubby will result in a cubby table with a row named default, you may override them like this

var cubbyOne = new Cubby({connection: connection, table: 'datastore', name: 'one'}),
    cubbyTwo = new Cubby({connection: connection, table: 'datastore', name: 'two'});

paths

cubby.setPath('one.two.three', true);
cubby.getPath('one.two.three');
cubby.getPath('one.two.three.four'); // returns undefined when value doesn't exist
Something went wrong with that request. Please try again.