atomicdb
A comprehensive database engine that works with arbitrary storage solutions and runs guaranteed atomic operations with additional support for encryption and compression
N/B: The code/examples in this file are in coffee-script. Javascript examples are coming soon.
Installation (NodeJS)
npm install atomicdb --save
Usage (NodeJS)
{ Atomicdb} = require 'atomicdb' db = new Atomicdb
Installation (Browser)
Download the latest build and put it in your application.
Features
- constructor
new Atomicdb
(Create a new Instance)
constructor
new Atomicdb options
options
is a object containing the following keys -
-
name
A name for the database. Must be unique on your host/domain. -
storageEngine
A storageEngine. Compatible withwindow.localStorage
,window.sessionStorage
. You can set your own. A custom storageEngine has to be roughly compatible with thewindow.localStorage
specs. Basically, it needs to implement the functions inwindow.localStorage
such asgetItem
,setItem
, etc. For in-memory operation, we suggest you use memorystorage module by stijndewitt -
serializationEngine
A way to serialize object to string and back. JSON.stringify and JSON.parse is a good example. You can of course set your own. As long as it has thestringify
andparse
methods, you are golden. -
commitDelay
Guarantees that there will be at leastcommitDelay
miliseconds delay between two subsequent commits. Useful if you have a big database or very frequent database changes. By default it is set to'none'
which commits synchronously. -
uniqueKey
Every document in atomicdb has a unique identifier key that can not be altered by the user/developer. You can specify the name of the unique key. It defaults to_id
as in mongodb.
Example:
db = new Atomicdb { name: 'test-db' storageEngine: localStorage serializationEngine: JSON commitDelay: 'none' uniqueKey: '_id'}