Compare commits
2 Commits
6c626e0b18
...
85adbbcdb3
Author | SHA1 | Date | |
---|---|---|---|
85adbbcdb3 | |||
5c0d266002 |
@ -124,12 +124,42 @@ async function getByIdBrand(brandId: string): Promise<IDbBrand | false> {
|
||||
return brand;
|
||||
}
|
||||
|
||||
//TODO get models of the brand
|
||||
|
||||
//TODO get stats of the brand
|
||||
|
||||
/**
|
||||
* Deletes a brand from the database.
|
||||
*
|
||||
* @param {string} brandId - The ID of the brand to delete.
|
||||
* @return {Promise<boolean>} - A promise that resolves to true if the brand was deleted successfully, or false otherwise.
|
||||
*/
|
||||
async function deleteBrand(brandId: string): Promise<boolean> {
|
||||
if (!brandId) {
|
||||
logger.error("Brand ID is missing");
|
||||
return false;
|
||||
}
|
||||
if (brandId.length !== 36) {
|
||||
logger.error("Invalid brand ID");
|
||||
return false;
|
||||
}
|
||||
//TODO verify if as models linked
|
||||
const deletedBrand = await MysqlService.Brand.delete(DbHandler, brandId);
|
||||
if (!deletedBrand) {
|
||||
logger.error(`Failed to delete brand (${brandId})`);
|
||||
return false;
|
||||
}
|
||||
logger.info(`Brand deleted successfully (${brandId})`);
|
||||
return true;
|
||||
}
|
||||
|
||||
const BrandService = {
|
||||
create: createBrand,
|
||||
update: updateBrand,
|
||||
getAll: getAllBrand,
|
||||
getBySlug: getBySlugBrand,
|
||||
getById: getByIdBrand,
|
||||
delete: deleteBrand,
|
||||
}
|
||||
|
||||
export default BrandService;
|
Loading…
x
Reference in New Issue
Block a user