npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

mq-node

v1.0.11

Published

Mysql node library

Downloads

1,225

Readme

mQ node

Mysql library inspired on mQ.php. Suporting JSON to create mysql queries. Using on module node-mysql

Example :

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)

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)

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)

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

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

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