feat(services): simplify SQL query keys generation in mysql service
Remove the condition to check 'id' while generating SQL query keys in the `mysql.service.ts`. Now, a map function is used directly resulting in cleaner and leaner code. Issue: #18 Signed-off-by: Mathis <yidhra@tuta.io>
This commit is contained in:
parent
5163d79056
commit
f6d18fc58d
@ -66,12 +66,7 @@ class MysqlHandler {
|
|||||||
try {
|
try {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
data.values.id ? delete data.values.id : null;
|
data.values.id ? delete data.values.id : null;
|
||||||
const _sqlQueryKeys = Object.keys(data.values).map((key: string) => {
|
const _sqlQueryKeys = Object.keys(data.values).map((key: string) => `\'${key}\' = ?`)
|
||||||
if (key !== 'id') {
|
|
||||||
return `\'${key}\' = ?`
|
|
||||||
}
|
|
||||||
return '';
|
|
||||||
})
|
|
||||||
const values = Object.values(data.values).map((val)=>val)
|
const values = Object.values(data.values).map((val)=>val)
|
||||||
this.Logger.debug(`\n\n>-> Factorized ${_sqlQueryKeys.length} keys for a prepare Query.\n>-> Action: ${data.actionName}\n`)
|
this.Logger.debug(`\n\n>-> Factorized ${_sqlQueryKeys.length} keys for a prepare Query.\n>-> Action: ${data.actionName}\n`)
|
||||||
const sqlQueryKeys = _sqlQueryKeys.join(', ')
|
const sqlQueryKeys = _sqlQueryKeys.join(', ')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user