mysql-simple-query
Advanced tools
Comparing version 1.0.12 to 1.0.13
@@ -53,4 +53,4 @@ const dbQuery = require('./util/dbQuery'); | ||
whereBetween(key, value) { | ||
this.whereLikeStatement[key] = value; | ||
whereBetween(key, array) { | ||
this.whereBetweenStatement[key] = array; | ||
} | ||
@@ -76,3 +76,3 @@ | ||
if (!isEmpty(this.whereBetweenStatement)) { | ||
return dbQuery.parseWhereBetween(this.whereBetweenStatement); | ||
return dbQuery.parseWhereBetween(this.whereBetweenStatement, this.whereConditionUsed); | ||
} | ||
@@ -79,0 +79,0 @@ |
@@ -68,3 +68,3 @@ const select = select => { | ||
const parseWhereBetween = whereObject => { | ||
const parseWhereBetween = (whereObject, where = false) => { | ||
let whereStatement = []; | ||
@@ -74,6 +74,6 @@ | ||
const value = whereObject[key]; | ||
whereStatement.push(`${key} BETWEEN "${value}"`); | ||
whereStatement.push(`${key} BETWEEN "${value[0]}" AND "${value[1]}"`); | ||
} | ||
return `${whereStatement.join(' AND ')}`; | ||
return `${where ? 'AND' : 'WHERE'} ${whereStatement.join(' AND ')}`; | ||
}; | ||
@@ -80,0 +80,0 @@ |
{ | ||
"name": "mysql-simple-query", | ||
"version": "1.0.12", | ||
"version": "1.0.13", | ||
"description": "Simple query wrapper for mysql-promise to make querying, inserting, updating, and deleting easier for developers.", | ||
@@ -5,0 +5,0 @@ "main": "mysqlSimpleQuery.js", |
@@ -54,4 +54,4 @@ const dbQuery = require('./util/dbQuery'); | ||
whereBetween(key, value) { | ||
this.whereBetweenStatement[key] = value; | ||
whereBetween(key, array) { | ||
this.whereBetweenStatement[key] = array; | ||
} | ||
@@ -77,3 +77,3 @@ | ||
if(!isEmpty(this.whereBetweenStatement)) { | ||
return dbQuery.parseWhereBetween(this.whereBetweenStatement); | ||
return dbQuery.parseWhereBetween(this.whereBetweenStatement, this.whereConditionUsed); | ||
} | ||
@@ -80,0 +80,0 @@ |
@@ -73,3 +73,3 @@ const select = (select) => { | ||
const parseWhereBetween = (whereObject) => { | ||
const parseWhereBetween = (whereObject, where = false) => { | ||
let whereStatement = []; | ||
@@ -79,6 +79,6 @@ | ||
const value = whereObject[key]; | ||
whereStatement.push(`${key} BETWEEN "${value}"`); | ||
whereStatement.push(`${key} BETWEEN "${value[0]}" AND "${value[1]}"`); | ||
} | ||
return `${whereStatement.join(' AND ')}`; | ||
return `${(where ? 'AND' : 'WHERE')} ${whereStatement.join(' AND ')}`; | ||
}; | ||
@@ -85,0 +85,0 @@ |
@@ -81,2 +81,25 @@ const expect = require('chai').expect; | ||
it('With where in between statement', () => { | ||
const test = new mysqlSimpleQuery(); | ||
test.select('*'); | ||
test.from('table'); | ||
test.whereBetween('column', ['1', '2']); | ||
const testResults = test.query(); | ||
expect(testResults).to.equal('SELECT * FROM table WHERE column BETWEEN "1" AND "2";'); | ||
}); | ||
it('With where in between and other where statement', () => { | ||
const test = new mysqlSimpleQuery(); | ||
test.select('*'); | ||
test.from('table'); | ||
test.where('key', '%value%'); | ||
test.whereBetween('column', ['1', '2']); | ||
const testResults = test.query(); | ||
expect(testResults).to.equal('SELECT * FROM table WHERE key="%value%" AND column BETWEEN "1" AND "2";'); | ||
}); | ||
it('Query with limit', () => { | ||
@@ -83,0 +106,0 @@ const test = new mysqlSimpleQuery(); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
29617
754