Skip to content

This is a wrapper over mysql and mysql-queues node.js packages.

Notifications You must be signed in to change notification settings

bharatpatil/DB.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 

Repository files navigation

DB.js

This is a wrapper over mysql and mysql-queues node.js packages.

Usage:
Initialize object


var dbClass = require('DB');
var options = {};
options.host = 'localhost';
options.user = 'root';
options.password = 'root';
options.database = 'test';
var db = new dbClass.DB(options);

Select statement

db.sql = 'select * from test where id = ? and name=?';
db.bindParams([id,name]);
db.select(function(err, results, fields){
..
..
});

Transaction statement

db.sql = 'insert into test (name) values (?)';
db.startTransaction();
db.insertTransaction(['bharat'],function(err, info) 
{
	if(err)
	{
		console.log('error');
		console.log(err);
		db.rollback();
	}
	else	
	{
		id = info.insertId;
		db.commit();
	}			    
});
db.executeTransaction();

About

This is a wrapper over mysql and mysql-queues node.js packages.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published