mysql-cubby

v0.0.0
simple mysql data storage
storage node json

cubby

a cubby that uses mysql

works well as a simple json datastore

installation

$ npm install cubby-mysql

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
npm i mysql-cubby

Metadata

  • MIT
  • Whatever
  • Chad Scira
  • released 12/7/2012

Downloads

Maintainers