Comparing version 0.0.8 to 0.0.9
@@ -65,4 +65,27 @@ const { TYPES, RELATION_TYPES } = require('./types') | ||
updateBy(conditions, values) { | ||
this.currentQuery = 'UPDATE ?? SET ? WHERE ?' | ||
this.conditions = [this.modelName, values, conditions] | ||
this.currentQuery = 'UPDATE ?? SET ' | ||
this.conditions = [this.modelName] | ||
Object.keys(values).reduce((currentQuery, valueKey) => { | ||
if ([TYPES.BOOLEAN, TYPES.INT, TYPES.STRING].includes(this.model[valueKey].type)) { | ||
if (currentQuery !== '') { | ||
this.currentQuery += ', ' | ||
} | ||
currentQuery += `${valueKey} = '${values[valueKey]}'` | ||
this.currentQuery += `${valueKey} = ?` | ||
this.conditions.push(values[valueKey]) | ||
} | ||
return currentQuery | ||
}, '') | ||
this.currentQuery += ' WHERE ' | ||
Object.keys(conditions).reduce((currentQuery, condition) => { | ||
if ([TYPES.BOOLEAN, TYPES.INT, TYPES.STRING].includes(this.model[condition].type)) { | ||
if (currentQuery !== '') { | ||
this.currentQuery += ', ' | ||
} | ||
currentQuery += `${condition} = '${conditions[condition]}'` | ||
this.currentQuery += `${condition} = ?` | ||
this.conditions.push(conditions[condition]) | ||
} | ||
return currentQuery | ||
}, '') | ||
return this | ||
@@ -69,0 +92,0 @@ } |
{ | ||
"name": "ormius", | ||
"version": "0.0.8", | ||
"version": "0.0.9", | ||
"main": "index.js", | ||
@@ -5,0 +5,0 @@ "author": "Adele Bendayan", |
@@ -1,5 +0,5 @@ | ||
![Statements](https://img.shields.io/badge/statements-43.13%25-red.svg?style=flat) | ||
![Branches](https://img.shields.io/badge/branches-38.77%25-red.svg?style=flat) | ||
![Functions](https://img.shields.io/badge/functions-55%25-red.svg?style=flat) | ||
![Lines](https://img.shields.io/badge/lines-43.04%25-red.svg?style=flat) | ||
![Statements](https://img.shields.io/badge/statements-80.58%25-yellow.svg?style=flat) | ||
![Branches](https://img.shields.io/badge/branches-71.92%25-red.svg?style=flat) | ||
![Functions](https://img.shields.io/badge/functions-78.57%25-red.svg?style=flat) | ||
![Lines](https://img.shields.io/badge/lines-80.95%25-yellow.svg?style=flat) | ||
# Ormius | ||
@@ -6,0 +6,0 @@ Simple Orm for mysql |
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
11980
304