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:
Mathis H (Avnyr) 2024-04-30 16:39:43 +02:00
parent 5163d79056
commit f6d18fc58d
Signed by: Mathis
GPG Key ID: DD9E0666A747D126

View File

@ -66,12 +66,7 @@ class MysqlHandler {
try {
// @ts-ignore
data.values.id ? delete data.values.id : null;
const _sqlQueryKeys = Object.keys(data.values).map((key: string) => {
if (key !== 'id') {
return `\'${key}\' = ?`
}
return '';
})
const _sqlQueryKeys = Object.keys(data.values).map((key: string) => `\'${key}\' = ?`)
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`)
const sqlQueryKeys = _sqlQueryKeys.join(', ')