mQ node
Mysql library inspired on mQ.php. Suporting JSON to create mysql queries. Using on module node-mysql
Example :
var mq = host : 'localhost' user : 'root' password : '' database : 'players'; mq; // return INSERT INTO players SET player="Lulu", goal=80
Query
mq.query(query[string],callback)
mq
Delete
mq.delete(table[string or array], where[string, object or array],callback)
mq; // return DELETE FROM test where player="Janna" mq; // return DELETE FROM test where player="Janna" and score=100 mq; // return DELETE FROM test where player="Janna" or score=100
Insert
mq.insert(table[string or array],set [string, object or array],callback)
mq; // return INSERT INTO players SET player="Lulu", goal=80 mq; // return INSERT INTO players SET player="Lulu" mq; // return INSERT INTO players SET player="Lulu"
Update
mq.update(table[string or array],set [string, object or array],where [string, object or array],callback)
mq.set // Alias
mq // return UPDATE test set goal=30 WHERE player="Janna"
Select
mq.select(data[object],callback)
mq.set // Alias
mq // RETURN SELECT player, goal, id FROM test WHERE player="Janna" // full data attributes mq
Single Row
mq.select({ from:'test', cols:['player','goal','id'], where:{player:'Janna'} },function(err,data){ },{single: true}) // output just one row as object
## Nest Tables Result (optional)
mysql.query('SELECT t1.name,t2.name FROM players as t1, teams as t2 WHERE t2.id=t1.team',function(err,data){ // result example : [ { t1: { name: 'Distillers 345' }, t2: { name: 'Heroes Team' } } ] },{nestTables: true})
## Debug Query
mysql.select({ from:'test', cols:['player','goal','id'], where:{player:'Janna'} },{debug: true}) // console.log -> SELECT player, goal, id, FROM test WHERE player="Janna";
## Node mysql object
mq.connection
## Install
```Batchfile
npm install mq-node
The MIT License