24 Commits

Author SHA1 Message Date
adaf4e30db
feat(services): update MySQL services with method adjustments
- Modified 'getById' reject message for accuracy.
- Adjusted 'getBySlug' method parameters for clarity and renamed the field used in the SQL statement.
- Added a new 'getById' method for retrieving models by ID.
- Updated the 'insert' method to correctly insert data into the `models` table.
- Refactored 'getBySlug' method for categories, renaming the parameter and making error messages more precise.

Issue: #7
Signed-off-by: Mathis <yidhra@tuta.io>
2024-04-26 11:09:26 +02:00
a811a2ece2
docs(services): add tasks to MySQL and Category services
An additional task is marked in the MySQL service to check if models are linked before taking further actions. Similarly, in the Category service, two tasks are added to verify the existence of a category and elements linked to it before proceeding with deletion.

Signed-off-by: Mathis <yidhra@tuta.io>
2024-04-26 09:57:44 +02:00
b1dacb750a
feat(services): add delete function in mysql service
A new delete function has been added to the `mysql.service.ts` file under services. This function deletes a brand from the database using the brandId. It throws an error if the brandId is undefined or invalid.

Issue: #5
Signed-off-by: Mathis <yidhra@tuta.io>
2024-04-25 16:40:42 +02:00
0ed130f7b8
feat(services): update MySQL service to fetch brand data
- Corrected the SQL query in fetching brand data based on ID.
- Added a new function, `getBySlug`, to fetch brand data using the brand slug. This ensures a flexible data access method thus enhancing the service's usability.

Issue: #5
Signed-off-by: Mathis <yidhra@tuta.io>
2024-04-25 16:38:41 +02:00
50c1ff797f
feat(services): add getById function to mysql.service
The code now includes a `getById` function in `mysql.service.ts`, which fetches a category by its id. This function will reject with an error message if brandId is not defined or if its length is not 36. The query is executed using a MysqlHandler instance.

Issue: #5
Signed-off-by: Mathis <yidhra@tuta.io>
2024-04-25 16:36:12 +02:00
a992868eb6
feat(services): add 'getAll' function to mysql.service.ts
A new function named `getAll` has been added to `mysql.service.ts`. This function is designed to retrieve all records from the `brands` table. It returns a promise that resolves to an array of `IDbBrand` objects representing the retrieved records.

Issue: #5
Signed-off-by: Mathis <yidhra@tuta.io>
2024-04-25 16:29:39 +02:00
44b04459fb
feat(services): add detailed comments and specify return types in mysql.service
In the `mysql.service`, this commit adds detailed doc-block comments for `insert` and `update` functions under `Brand` and `Category`. Additionally, the return types of the `update` functions under `Brand` and `Category` are now specifically defined as `Promise<number>`, providing clarity on the expected returns.

Issue: #5
Signed-off-by: Mathis <yidhra@tuta.io>
2024-04-25 16:26:29 +02:00
64aa814d2c
feat(services): add update method to mysql service
An `update` method is added to the `mysql.service.ts` for handling database updates. This new function checks for validity of the `id` before constructing and executing an SQL update statement. Errors are also caught and handled.

Issue: #5
Signed-off-by: Mathis <yidhra@tuta.io>
2024-04-25 16:24:02 +02:00
016f7fa9d4
feat(services): add brand insert method in mysql service
- Adjusted import syntax for IDbCategory interface
- Imported IDbBrand from database interfaces
- Added a new `insert` method in Brand object in MysqlHandler to insert brand data into the database. The method resolves with execution of SQL command and rejects on error or invalid ID.

Issue: #5
Signed-off-by: Mathis <yidhra@tuta.io>
2024-04-25 16:19:27 +02:00
01241dff4b
fix(services): correct database table name in mysql.service.ts
Update the hardcoded table name in the raw SQL query within mysql.service.ts. We changed `categorys` to `categories` to align with the actual database schema.

Signed-off-by: Mathis <yidhra@tuta.io>
2024-04-25 16:07:29 +02:00
73e086be44
docs(services): add TODO comment in mysql.service
A TODO comment has been added in the mysql.service.ts file as a reminder to get models in category in the future. This is to ensure that future development accounts for this necessity.

Signed-off-by: Mathis <yidhra@tuta.io>
2024-04-25 14:22:25 +02:00
0abdbab627
feat(services): add getById and delete methods in mysql.service.ts
The changes introduce two new methods in mysql.service.ts. The getById method retrieves a category from the database using its ID while the delete method will delete a category from the database using the provided category ID. Both methods return promises.

Issue: #6
Signed-off-by: Mathis <yidhra@tuta.io>
2024-04-25 12:52:42 +02:00
3328c5a1df
feat(services): add getById function to mysql.service
This commit adds a getById function to the mysql.service.ts file. The added functionality allows retrieving category data from the mysql database by id. Error handling has been included for undefined or invalid id cases.

Issue: #6
Signed-off-by: Mathis <yidhra@tuta.io>
2024-04-25 12:30:32 +02:00
ead64291df
feat(services): add getBySlug method to MysqlService and refine getAll method
Added a new method getBySlug to retrieve a category by its slug in mysql.service.ts. Also, updated the getAll method by specifying the return type to Promise<Array<IDbCategory>> for better type checking.

Issue: #6
Signed-off-by: Mathis <yidhra@tuta.io>
2024-04-25 12:27:25 +02:00
02383b8c8a
feat(services): add getAll function to mysql service
This commit adds a new `getAll` function in the `mysql.service.ts` file, which retrieves all categories from the database. It executes a SQL query and includes error handling that either resolves with an array of category objects or rejects with an Error object.

BREAKING-CHANGE: #6
Signed-off-by: Mathis <yidhra@tuta.io>
2024-04-25 12:18:33 +02:00
2210280edd
feat(services): update return types and add documentation in mysql service
The return types for the 'insert' and 'update' methods in mysql.service.ts have been updated to 'Promise<unknown>'. Also, detailed JSDoc comments have been added for 'insert' and 'update' methods for both User and Category entities. No functionality changes have been made.

Signed-off-by: Mathis <yidhra@tuta.io>
2024-04-25 12:11:17 +02:00
47adae9137
feat: Update MySQL service for category operations
This update introduces changes in the 'mysql.service.ts' to allow create and update operations for categories. The 'INSERT INTO' SQL query has been adjusted from targeting `users` to `categories`. An `update` function has also been added to allow updates in category data. The import order has been rearranged for better readability.

Signed-off-by: Mathis <yidhra@tuta.io>
2024-04-25 12:01:02 +02:00
ef83ad18a4
feat(services): Db - category insert method
#6
2024-04-25 11:37:09 +02:00
adbecfa435
style(services): 🎨 Db 2024-04-25 11:36:20 +02:00
6a54dd0afa
feat(services): Db - partial insert method for 'model' 2024-04-24 16:55:15 +02:00
ccee786c2f
feat(services): 🎉 db - models getters interaction
#7
2024-04-24 15:07:45 +02:00
69fae2b780
feat(services): db - user interaction
#4
2024-04-24 15:04:44 +02:00
742330d6fe
refactor(services): 🏗️ var name change
#9
2024-04-23 15:12:41 +02:00
ad0f30876e
feat: MySQL Service 2024-04-23 13:44:58 +02:00