Compare commits

..

No commits in common. "91b88ea59266d35bed4b3281768a29463dabf435" and "a9cf48b04a848147ebba73eb9f7752bdfef1ff74" have entirely different histories.

2 changed files with 6 additions and 7 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "brief-05-back", "name": "brief-05-back",
"version": "1.1.0", "version": "1.0.0",
"description": "", "description": "",
"main": "src/app.ts", "main": "src/app.ts",
"keywords": [], "keywords": [],

View File

@ -92,15 +92,14 @@ const MySqlService = {
User: { User: {
/** /**
* Inserts a new user into the database. * Insert a user into the database.
* *
* @param {MysqlHandler} handler - The MySQL database handler. * @param {MysqlHandler} handler - The MySQL database handler.
* @param {IDbUser} data - The user data to insert. * @param {IDbUser} data - The user data to insert.
* @returns {Promise<IDbStatusResult>} A promise that resolves with the database status result. * @returns {Promise<unknown>} A promise that resolves if the user was inserted successfully, or rejects with an error.
* @throws {Error} If an error occurs during the execution. * @throws {Error} If an error occurs while executing the query.
* @throws {string} If the `id` field is undefined or invalid.
*/ */
insert(handler: MysqlHandler, data: IDbUser): Promise<IDbStatusResult> { insert(handler: MysqlHandler, data: IDbUser): Promise<unknown> {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
if (!data.id) return reject('Id is undefined'); if (!data.id) return reject('Id is undefined');
if (data.id.length !== 36) return reject('Id invalid'); if (data.id.length !== 36) return reject('Id invalid');
@ -119,7 +118,7 @@ const MySqlService = {
data.hash data.hash
] ]
try { try {
resolve(handler.execute(_sql, _values) as unknown as IDbStatusResult) resolve(handler.execute(_sql, _values) as unknown)
} catch (err: unknown) { } catch (err: unknown) {
reject(err as Error); reject(err as Error);
} }