This package has been deprecated

Author message:

deprecated

local-database

1.0.1 • Public • Published

local-database

Methods

localedb = {
  SET(namespace, data, params),
  GET(namespace, params),
  REMOVE(namespace, params),
  REMOVE_ALL(namespace)
}

All methods throw a result array. If you get a data and want access it you need check if the your_method.error.value is set to false unless your action failed. Then you can get your data accessing the your_method.success.data

{
  error: {
    // If the method failed or not (true, false).
    value: null,
    // Message associated with failure action.
    message: null
  },
  success: {
    // Message associated with success action.
    message: null,
    // If the data is supposed to return a value, you will access here.
    data: null
  }
}

SET(namespace, data, params = undefined)

param type optional
namespace database name no
data data to set no
params function bind with findIndex to edit a specific data yes
  • usage
// 1. On create
var data = {id: 0, name: root, lvl: 100};
localdb.SET('database_test', data);

// 2. On update
var data = {id: 0, name: root, lvl: 100};
function findData(d) {
  return d.name == "root";
}
localedb.SET('database_test', data, findData);

GET(namespace, params = undefined)

param type optional
namespace database name no
params function bind with filter to get a specific data yes
  • usage
// 1. Getting all data
var myDataBase = localdb.GET('database_test');

// 2. Getting filtered data
function filterData(d) {
  return d.lvl >= 50;
}
var myDataBase = localdb.GET('database_test', myDataBase);

REMOVE(namespace, params)

param type optional
namespace database name no
params function bind with findIndex to remove a specific data no
  • usage
// 1 Removing a data
function findData(d) {
  return d.name == "root";
}
localdb.REMOVE('database_test', findData);

REMOVE_ALL(namespace)

param type optional
namespace database name no
  • usage
// 1 Removing all data
localdb.REMOVE_ALL('database_test);

Package Sidebar

Install

npm i local-database

Weekly Downloads

2

Version

1.0.1

License

ISC

Last publish

Collaborators

  • npm