JSPM

  • Created
  • Published
  • Downloads 128
  • Score
    100M100P100Q102026F

EJDB - Embedded JSON Database engine

Package Exports

  • ejdb

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (ejdb) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

EJDB NodeJS binding http://ejdb.org

Join the chat at https://gitter.im/Softmotions/ejdb

Installation

http://ejdb.org/doc/bindings/nodejs/index.html

API

http://ejdb.org/doc/bindings/nodejs/api.html

One snippet intro

var EJDB = require("ejdb");
//Open zoo DB
var jb = EJDB.open("zoo",
                    EJDB.DEFAULT_OPEN_MODE | EJDB.JBOTRUNC);

var parrot1 = {
    "name" : "Grenny",
    "type" : "African Grey",
    "male" : true,
    "age" : 1,
    "birthdate" : new Date(),
    "likes" : ["green color", "night", "toys"],
    "extra1" : null
};
var parrot2 = {
    "name" : "Bounty",
    "type" : "Cockatoo",
    "male" : false,
    "age" : 15,
    "birthdate" : new Date(),
    "likes" : ["sugar cane"]
};

jb.save("parrots", [parrot1, parrot2], function(err, oids) {
    if (err) {
        console.error(err);
        return;
    }
    console.log("Grenny OID: " + parrot1["_id"]);
    console.log("Bounty OID: " + parrot2["_id"]);

    jb.find("parrots",
            {"likes" : "toys"},
            {"$orderby" : {"name" : 1}},
            function(err, cursor, count) {
                if (err) {
                    console.error(err);
                    return;
                }
                console.log("Found " + count + " parrots");
                while (cursor.next()) {
                    console.log(cursor.field("name") + " likes toys!");
                }
                //It's not mandatory to close cursor explicitly
                cursor.close();
                jb.close(); //Close the database
            });
});