ecdb
v0.2.11
Published
Make DB operation Easy
Downloads
14
Readme
ecDB
Make DB operation Easy
Install
https://www.npmjs.com/package/ecdb
npm install ecdb
Use
var ECDB = require('ecdb');
var ecDB = new ECDB();
ecDB.connect();
Use MongoDB
var ECDB = require('ecdb');
var ecDB = new ECDB({"driver": "EasyMongo"});
ecDB.connect({"url": "mongodb://127.0.0.1"});
Insert Data
ecDB would auto create the table and schema with your data
- insert single row
ecDB.postData(
'users',
{name: 'WEI', birth: '1982-04-01', age: 33},
function(error, result) {console.log(result);}
);
- insert multiple rows
ecDB.postData(
'users',
[
{name: 'WEI', birth: '1982-04-01', age: 33},
{name: 'Becca', birth: '1985-07-18', age: 30},
{name: 'Gary', birth: '1989-12-11', age: 26}
],
function(error, result) {console.log(result);}
);
List All Tables
ecDB.listTable(function(error, result) {console.log(result);});
Get Table Schema
ecDB.getTable('users', function(error, result) {console.log(result);});
List Data in Table
- List all data
ecDB.listData('TableName', function(error, result) {console.log(result);});
- You can also use search query
ecDB.listData(
'users',
'where birth > "1988-01-01"',
function(error, result) {console.log(result);}
);
Search JSON data
ecDB.dataFind(
[
{path: '/aaa/bbb/ccc/'},
{path:'/aaa/bbb'},
{path:'/aaa/bbb/qqq/'}
],
'where path like "*/bbb/*"',
function(error, result) {
console.log(result);
}
);