# mq-node

> Mysql node library

Latest version **1.0.11** (published 2015-09-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install mq-node
pnpm add mq-node
yarn add mq-node
bun add mq-node
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.11 |
| Published | 2015-09-23 |
| First published | 2015-08-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 (+6 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Andre Caetano |
| Maintainers | webcaetano |
| Keywords | node, mysql, library, sql, database |

## Links

- npm: https://www.npmjs.com/package/mq-node
- Repository: https://github.com/webcaetano/mq-node
- Issues: https://github.com/webcaetano/mq-node/issues
- npm.io page: https://npm.io/package/mq-node

## Dependencies (3)

- [mysql](https://npm.io/package/mysql.md) ^2.8.0
- [lodash](https://npm.io/package/lodash.md) ^3.10.1
- [source-map-support](https://npm.io/package/source-map-support.md) ^0.3.2

## Alternatives

- [@libsql/sqlite3](https://npm.io/package/@libsql/sqlite3.md) — 39.8K weekly downloads
- [@fortemi/core](https://npm.io/package/@fortemi/core.md) — 461 weekly downloads
- [cdb-converter](https://npm.io/package/cdb-converter.md) — 341 weekly downloads
- [@uplo/adapter-prisma](https://npm.io/package/@uplo/adapter-prisma.md) — 75 weekly downloads
- [typeorm-aios](https://npm.io/package/typeorm-aios.md) — 30 weekly downloads

## Recent versions

- 1.0.11 (latest) — 2015-09-23
- 1.0.10 — 2015-09-23
- 1.0.9 — 2015-09-23
- 1.0.8 — 2015-09-21
- 1.0.7-1 — 2015-09-21
- 1.0.7 — 2015-09-18
- 1.0.5 — 2015-09-18
- 1.0.4 — 2015-09-17
- 1.0.3 — 2015-09-16
- 1.0.1-2 — 2015-08-19
- 1.0.1-1 — 2015-08-19
- 1.0.1 — 2015-08-19
- 1.0.0 — 2015-08-17

## README

# mQ node

Mysql library inspired on [mQ.php](https://github.com/webcaetano/mQ). 
Suporting JSON to create mysql queries. 
Using on module [node-mysql](https://github.com/felixge/node-mysql/)

Example :

```javascript
var mq = require('mq-node')({
	host     : 'localhost',
	user     : 'root',
	password : '',
	database : 'players'
});

mq.insert('players',{
	player:'Lulu',
	goal:80
}); 

// return INSERT INTO players SET player="Lulu", goal=80
```

## Query

mq.query(query[string],callback)

```javascript
mq.query('SELECT 1+1 as s',function(err,data){
	//result data[0]['s'] 2
})
```

## Delete

mq.delete(table[string or array], where[string, object or array],callback)

```javascript
mq.delete('test',{player:'Janna'},function(err,data){
});

// return DELETE FROM test where player="Janna"

mq.delete('test',{'player:"Janna"','score=100'},function(err,data){
});

// return DELETE FROM test where player="Janna" and score=100

mq.delete('test','player:"Janna" or score=100',function(err,data){
});

// return DELETE FROM test where player="Janna" or score=100
```

## Insert 

mq.insert(table[string or array],set [string, object or array],callback)

```javascript
mq.insert('players',{
	player:'Lulu',
	goal:80
}); 

// return INSERT INTO players SET player="Lulu", goal=80

mq.insert('players',[
	'player="Lulu"',
	'goal=80'
]); 

// return INSERT INTO players SET player="Lulu"

mq.insert('players','player="Lulu", goal=80'); 

// 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

```javascript
mq.update('test',{goal:30},{player:'Janna'},function(err,data){
})

// return UPDATE test set goal=30 WHERE player="Janna"
```

## Select 

mq.select(data[object],callback)

mq.set // Alias

```javascript
mq.select({
	from:'test',
	cols:['player','goal','id'],
	where:{player:'Janna'}
},function(err,data){
})

// RETURN SELECT player, goal, id FROM test WHERE player="Janna"

// full data attributes

mq.select({
	from:'test', // [string or array]
	cols:['player','goal','id'], // [string or array]
	where:{player:'Janna'}, // [string, array or object]
	group:'goal', // [string or array]
	order:'goal DESC', // [string or array]
	limit:'0,10', // [string or array]
	have:'player="Janna"', // [string or array]
},function(err,data){
})
```

## 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](https://raw.githubusercontent.com/webcaetano/mq-node/master/LICENSE.md)

---
_Source: https://npm.io/package/mq-node · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
