Compare commits
No commits in common. "5163d790563e4cf2b1b794bcc77a612eee8992ea" and "bc12f94e41a8dcf236c2fc515593658f10bee498" have entirely different histories.
5163d79056
...
bc12f94e41
@ -56,7 +56,6 @@ class MysqlHandler {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Factorize the input data values into a database query.
|
* Factorize the input data values into a database query.
|
||||||
* `id` field will not be injected in result to avoid problems.
|
|
||||||
*
|
*
|
||||||
* @param {IDbFactorizeInput} data - The input data containing values to factorize.
|
* @param {IDbFactorizeInput} data - The input data containing values to factorize.
|
||||||
* @return {Promise<IDbFactorizeOutput>} - A promise resolving to the factorized output.
|
* @return {Promise<IDbFactorizeOutput>} - A promise resolving to the factorized output.
|
||||||
@ -64,14 +63,7 @@ class MysqlHandler {
|
|||||||
factorize(data: IDbFactorizeInput): Promise<IDbFactorizeOutput> {
|
factorize(data: IDbFactorizeInput): Promise<IDbFactorizeOutput> {
|
||||||
return new Promise((resolve, reject)=>{
|
return new Promise((resolve, reject)=>{
|
||||||
try {
|
try {
|
||||||
// @ts-ignore
|
const _sqlQueryKeys = Object.keys(data.values).map((key: string) => `\'${key}\' = ?`)
|
||||||
data.values.id ? delete data.values.id : null;
|
|
||||||
const _sqlQueryKeys = Object.keys(data.values).map((key: string) => {
|
|
||||||
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(', ')
|
||||||
@ -366,10 +358,17 @@ const MySqlService = {
|
|||||||
if (data.id.length !== 36) return reject("Id invalid");
|
if (data.id.length !== 36) return reject("Id invalid");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
handler.factorize({
|
const _template = `
|
||||||
values: data,
|
${data.slug_name ? "`slug_name` = ?," : null}
|
||||||
actionName: `Update user ID::${data.id}`
|
${data.display_name ? "`display_name` = ?," : null}
|
||||||
})
|
${data.image_blob ? "`slug_name` = ?," : null}`;
|
||||||
|
|
||||||
|
const _values = [
|
||||||
|
data.slug_name,
|
||||||
|
data.display_name,
|
||||||
|
data.image_blob,
|
||||||
|
data.id,
|
||||||
|
];
|
||||||
const _sql = `UPDATE "brands" SET ${_template} WHERE 'id' = ?`;
|
const _sql = `UPDATE "brands" SET ${_template} WHERE 'id' = ?`;
|
||||||
handler.execute(_sql, _values).then((result) => {
|
handler.execute(_sql, _values).then((result) => {
|
||||||
return resolve(result as unknown as IDbStatusResult);
|
return resolve(result as unknown as IDbStatusResult);
|
||||||
|
@ -75,19 +75,6 @@ async function getUserFromIdService(id: string): Promise<IDbUser | ISError> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
DbHandler.factorize({
|
|
||||||
values: {
|
|
||||||
id: '011010101',
|
|
||||||
username: 'avnyr',
|
|
||||||
age: 42,
|
|
||||||
is_admin: true
|
|
||||||
},
|
|
||||||
actionName: "Testing"
|
|
||||||
}).then((result)=>{
|
|
||||||
logger.trace(`\n\n> ${result._valuesArray.join(', ')}\n\n> ${result.totalFields}\n\n> ${result._keysTemplate}\n`)
|
|
||||||
})*/
|
|
||||||
|
|
||||||
//ToTest
|
//ToTest
|
||||||
/**
|
/**
|
||||||
* Registers a new user.
|
* Registers a new user.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user