Skip to content
All the database you will ever need.
CoffeeScript JavaScript Makefile
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
src
test
.gitignore
Makefile
README.md
index.js
package.json

README.md

Dirtle

Warning: Do not use this for real things. You will lose data.

Database done right.

What?

Dirtle is a fast, in-memory, persistent JSON store for node.js with synchroneous but non-blocking access.

How?

Easy.

  1. Install it.

    npm i dirtle
  2. Create the database.

    echo '{}' > db.json
  3. Use it.

    var Dirtle = require('dirtle');
    var path = require('path');
    var db = new Dirtle(path.join(__dirname, 'db.json')).db;
    
    db.users = [];
    db.users.push({ name : 'hohoho' });
    db.pages = {
        home: 'Home Page',
        profile: 'My Profile'
    };
  4. Look at the database from outside.

    $ cat db.json | pjson
      {
        "pages": {
          "home": "Home Page", 
          "profile": "My Profile"
        }, 
        "users": [
          {
            "name": "hohoho"
          }
        ]
      }

How does it work?

When creating an instance of Dirtle, the Database is being loaded into memory synchroneously from a JSON file. It is being dumped non-blockingly to disk once every 470 milliseconds by default and once when the application exits.

You use it just like a native Object in JavaScript. However, it has to pass through JSON.stringify or the app will crash.

API

var db = new Dirtle(path[, timeout]).db;

path is the path to the database json text file. timeout is an optional timeout in ms, when the db will be persisted to disk (default 470ms).

Something went wrong with that request. Please try again.