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