mysql-simple-query
Advanced tools
Comparing version 1.0.3 to 1.0.4
@@ -9,2 +9,4 @@ const dbQuery = require('./util/dbQuery'); | ||
this.whereStatement = {}; | ||
this.whereLikeStatement = {}; | ||
this.whereLikeCondition = null; | ||
this.groupByStatement = ''; | ||
@@ -40,2 +42,10 @@ this.orderByStatement = ''; | ||
whereLike(key, value, condition) { | ||
this.whereLikeStatement[key] = value; | ||
if (condition) { | ||
this.whereLikeCondition = condition; | ||
} | ||
} | ||
parseWhere() { | ||
@@ -49,2 +59,10 @@ if (!isEmpty(this.whereStatement)) { | ||
parseWhereLike() { | ||
if (!isEmpty(this.whereLikeStatement)) { | ||
return dbQuery.parseWhereLike(this.whereLikeStatement, this.whereLikeCondition); | ||
} | ||
return ''; | ||
} | ||
groupBy(key) { | ||
@@ -90,2 +108,6 @@ if (key) { | ||
if (this.parseWhereLike() !== '') { | ||
queryStatement += ` ${this.parseWhereLike()}`; | ||
} | ||
if (this.groupByStatement !== '') { | ||
@@ -92,0 +114,0 @@ queryStatement += ` ${this.groupByStatement}`; |
@@ -53,2 +53,17 @@ const select = select => { | ||
const parseWhereLike = (whereObject, orStatement = false) => { | ||
let whereStatement = []; | ||
for (let key of Object.keys(whereObject)) { | ||
const value = whereObject[key]; | ||
whereStatement.push(`${key} LIKE "${value}"`); | ||
} | ||
if (orStatement) { | ||
return `WHERE ${whereStatement.join(' OR ')}`; | ||
} | ||
return `WHERE ${whereStatement.join(' AND ')}`; | ||
}; | ||
const groupBy = key => { | ||
@@ -94,2 +109,3 @@ if (key) { | ||
parseWhere, | ||
parseWhereLike, | ||
groupBy, | ||
@@ -96,0 +112,0 @@ orderBy, |
{ | ||
"name": "mysql-simple-query", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "Simple query wrapper for mysql-promise to make querying, inserting, updating, and deleting easier for developers.", | ||
@@ -5,0 +5,0 @@ "main": "mysqlSimpleQuery.js", |
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
25076
632