2.0.0 • Published 8 years ago

object-db v2.0.0

Weekly downloads
11
License
Apache-2.0
Repository
github
Last release
8 years ago

object-db

In browser JavaScript object storage. Get, Set, and Subscribe. Works across browser tabs and windows. Just 2kb.

Installation:

Simply install using npm.

npm install --save object-db

Usage

// Require ObjectDB
const ObjectDB = require('object-db');

// Init the DB, you can pass an object to init as a template (optional).
let myDB = new ObjectDB('test_db').init({ sweet: true });

// You can also subscribe to the DB.
myDB.subscribe((data) => {
  console.log(data);
});

// Await a specific item
myDB.await('example', example => {
	console.log('your await happened', example);
});

// Get all database contents.  
console.log(
  myDB.get()
);

// Get database item.
myDB.get('tested');

/// Remove a database item.
myDB.remove('tested');

// Purge and re-init the database.
myDB.purge().init();


// Triggers await, and subscribe.
myDB.set({
	example: 'boom'
});

setTimeout(function() {
  // Triggers await, and subscribe again.
  myDB.set({
    example: 'boom'
  });
}, 1500);
2.0.0

8 years ago

1.2.4

8 years ago

1.2.3

8 years ago

1.2.2

8 years ago

1.2.1

8 years ago

1.2.0

8 years ago

1.1.2

8 years ago

1.1.0

8 years ago

1.0.0

8 years ago