arya-dbconnect
v1.1.1
Published
Arya dbconnect is the node library to manage DB Connections with capillary DB services
Downloads
22
Readme
Arya DB Connect
A library that handles db operations of capillary db services with shard support
Installation
add dependency package in your package.json.
{"arya-dbconnect": "[email protected]:Capillary/arya-dbconnect.git"}
npm install arya-dbconnect
[don't use it for now] [TODO]
Usage
var DBase = require('arya-dbconnect');
var dObject = new DBase({dbname:"authorization"});
1. Output should be number of affected rows
dObject.query("select * from {{table}} where id = ?",[{{id}}])
.then(function(rows){
console.log(rows);
});
2. Output should be latest inserted id
dObject.insert(
"INSERT INTO {{table}} (`name`) VALUES (?)",['nayan1'])
.then(function(rows){
console.log(rows);
});
3. Output should be true or false
dObject.update(
"UPDATE {{table}} SET {{col}}=? where id = ?",["{{value}}","{{id}}"])
.then(function(rows){
console.log(rows);
});
4. Output should be number of affected rows
DBase.queryForOrg(
"select * from {{table}} where id = ?",[{{id}}],
{
"orgId":{{orgId}},
dbname:"{{dbname}}",
slave:{{true|false}}(optional)
})
.then(function(rows){
console.log(rows);
});
5. Output should be true or false
DBase.updateForOrg(
"UPDATE {{table}} SET {{col}}=? where id = ?",["{{val}}","{{id}}"],
{
"orgId":{{orgId}},
dbname:"{{dbname}}",
slave:{{true|false}}(optional)
})
.then(function(rows){
console.log(rows);
});
Tests
npm test
Contributing
In lieu of a formal style guide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code.