Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mysql-query-builder-js

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mysql-query-builder-js - npm Package Compare versions

Comparing version 0.0.3 to 0.0.5

src/where.js

103

index.js

@@ -32,5 +32,3 @@ /*

this._fields = [];
this._clausales = [];
this.connectionTest = function(){

@@ -47,25 +45,6 @@ if(!this.connection){

}
this.getWhere = function(){
if(this._clausales.length>0){
var str = " WHERE ";
for(var i in this._clausales){
var cl = this._clausales[i];
if(i == 0){
str += cl.where;
}else{
if(cl.type == 1){
str+=" AND "+cl.where;
}else{
str+=" OR "+cl.where;
}
}
}
return str;
}else{
return '';
}
}
}
Builder.prototype = require('./src/where.js');
/**

@@ -133,76 +112,2 @@ * Database connection

/**
* Where
* @param {String|Array} params
* @return {Object} this
*/
Builder.prototype.where = function(param){
this.tableTest();
if(arguments.length > 1){
if(arguments.length > 2){
this._clausales.push({
type:1,
where: arguments[0] + " " + arguments[1] + " '" + arguments[2] + "'"
});
}else{
this._clausales.push({
type:1,
where: arguments[0] + " = '" + arguments[1] + "'"
});
}
}else{
for(var i = 0 ; i < param.length; i++){
if(param[i].length > 2){
this._clausales.push({
type:1,
where: param[i][0] + " " + param[i][1] + " '" + param[i][2] + "'"
});
}else{
this._clausales.push({
type:1,
where: param[i][0] + " = '" + param[i][1] + "'"
});
}
}
}
return this;
}
/**
* Where Or
* @param {String|Array} params
* @return {Object} this
*/
Builder.prototype.whereOr = function(param){
this.tableTest();
if(arguments.length > 1){
if(arguments.length > 2){
this._clausales.push({
type:2,
where: arguments[0] + " " + arguments[1] + " '" + arguments[2] + "'"
});
}else{
this._clausales.push({
type:2,
where: arguments[0] + " = '" + arguments[1] + "'"
});
}
}else{
for(var i = 0 ; i < param.length; i++){
if(param[i].length > 2){
this._clausales.push({
type:2,
where: param[i][0] + " " + param[i][1] + " '" + param[i][2] + "'"
});
}else{
this._clausales.push({
type:2,
where: param[i][0] + " = '" + param[i][1] + "'"
});
}
}
}
return this;
}
/**
* Get query result

@@ -214,2 +119,5 @@ *

Builder.prototype.get = function(callback){
this.connectionTest();
this.tableTest();
this._fields = (this._fields.length>0)?this._fields:['*'];
this.sql = "SELECT "+this._fields.join(',')+" FROM "+this._table+this.getWhere();

@@ -224,2 +132,3 @@

module.exports = new Builder();
{
"name": "mysql-query-builder-js",
"version": "0.0.3",
"version": "0.0.5",
"description": "Query builder for mysql in Node.js",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -11,8 +11,9 @@ var builder = require('../index');

builder.table('pessoas')
.select('nome','email')
.where('id','>',1)
.whereOr('email','like','%jay%')
.whereNotIn('id',[1,2])
.get(function(err, rows, fields, sql){
console.log(sql)
if(err){
console.log(err)
}
console.log(rows)
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc