thinkdb

1.0.4 • Public • Published

Installation

$ npm install thinkdb

Import

var DB = require("thinkdb");

Configure

DB.domain = "localhost";
DB.port = "27017";//27017 default
DB.projectname = "es6";//name collection

New Table

DB.newtable("myTableName", ["name", "age", "city"]);
DB.newtable("myOtherTableName", ["dog", "cat", "human"]);

Approval

var newdata = ["eliasruizh", 19, "México City"];
var approval = DB.approval("myTableName",newdata);
if(approval != false){
    (yes)
    ...
}
var approval2 = DB.approval("myOtherTableName",newdata);
if(approval2 != false){
    (not)
    ...
}

Save approval

if(approval != false){
    DB.insert(approval, function(result){
        console.log(result);
    },"myTableName");
}

Find & FindOne

DB.find({age:19},fucntion(documents){
	console.log(documents.length);
	if(documents.length > 0){
	    console.log(documents[0].name);//eliasruizh
	}
},"myTableName");

DB.findOne({age:19},fucntion(document){
	console.log(document.name);//eliasruizh
},"myTableName");

Update

DB.update({age:19},{name:"@eliasruizhz"},fucntion(result){
	console.log(result);
},"myTableName");

Remove

DB.remove({name:"@eliasruizhz"},fucntion(result){
	console.log(result);//true:1
},"myTableName");

DB.remove({},fucntion(result){
	console.log(result);//false:0
},"myTableName");

License

ISC - http://www.think-lab.com.mx/

Package Sidebar

Install

npm i thinkdb

Weekly Downloads

5

Version

1.0.4

License

ISC

Last publish

Collaborators

  • eliasruizhz