Nihilist Pocket Monsters
Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

ejdb

1.2.12-42 • Public • Published

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
            });
});
 

install

npm i ejdb

Downloadsweekly downloads

24

version

1.2.12-42

license

none

homepage

ejdb.org

repository

githubgithub

last publish

collaborators

  • avatar
  • avatar