feat(services): update return type in mysql.service
The return type for the update function in mysql.service is updated from Promise<unknown> to Promise<IDbStatusResult>. Also, the function resolves with the status result of the update instead of just being successful. Issue: #17 Signed-off-by: Mathis <yidhra@tuta.io>
This commit is contained in:
parent
91b88ea592
commit
cda313866f
@ -126,14 +126,16 @@ const MySqlService = {
|
||||
})
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Updates user data in the database.
|
||||
* @param {MysqlHandler} handler - The MySQL handler object.
|
||||
* @param {IDbUser} data - The user data to be updated.
|
||||
* @returns {Promise<unknown>} - A promise that resolves when the update is successful.
|
||||
* @throws {Error} - If an error occurs during the update process.
|
||||
* Updates a user in the database.
|
||||
*
|
||||
* @param {MysqlHandler} handler - The MySQL database handler.
|
||||
* @param {IDbUser} data - The data of the user to update.
|
||||
* @returns {Promise<IDbStatusResult>} - A promise that resolves with the status result of the update.
|
||||
* @throws {Error} - If an error occurs during the update.
|
||||
*/
|
||||
update(handler: MysqlHandler, data: IDbUser): Promise<unknown> {
|
||||
update(handler: MysqlHandler, data: IDbUser): Promise<IDbStatusResult> {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (!data.id) return reject('Id is undefined');
|
||||
if (data.id.length !== 36) return reject('Id invalid');
|
||||
@ -163,7 +165,7 @@ const MySqlService = {
|
||||
]
|
||||
|
||||
const _sql = `UPDATE "users" SET ${_template} WHERE 'id' = ?`;
|
||||
return resolve(handler.execute(_sql, _values));
|
||||
return resolve(handler.execute(_sql, _values) as unknown as IDbStatusResult);
|
||||
|
||||
} catch (err: unknown) {
|
||||
reject(err as Error);
|
||||
|
Loading…
x
Reference in New Issue
Block a user