From cda313866f716cf3c2a0915af05f109b174ed20a Mon Sep 17 00:00:00 2001 From: Mathis Date: Tue, 30 Apr 2024 10:01:14 +0200 Subject: [PATCH] feat(services): update return type in mysql.service The return type for the update function in mysql.service is updated from Promise to Promise. Also, the function resolves with the status result of the update instead of just being successful. Issue: #17 Signed-off-by: Mathis --- src/services/mysql.service.ts | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/services/mysql.service.ts b/src/services/mysql.service.ts index cd379b9..052e897 100644 --- a/src/services/mysql.service.ts +++ b/src/services/mysql.service.ts @@ -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} - 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} - 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 { + update(handler: MysqlHandler, data: IDbUser): Promise { 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);