Compare commits
No commits in common. "85adbbcdb35db83c6cb53c7094e33848667da771" and "6c626e0b18a511298eee818ba7e2e3cf1fe92933" have entirely different histories.
85adbbcdb3
...
6c626e0b18
@ -124,42 +124,12 @@ async function getByIdBrand(brandId: string): Promise<IDbBrand | false> {
|
|||||||
return brand;
|
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 = {
|
const BrandService = {
|
||||||
create: createBrand,
|
create: createBrand,
|
||||||
update: updateBrand,
|
update: updateBrand,
|
||||||
getAll: getAllBrand,
|
getAll: getAllBrand,
|
||||||
getBySlug: getBySlugBrand,
|
getBySlug: getBySlugBrand,
|
||||||
getById: getByIdBrand,
|
getById: getByIdBrand,
|
||||||
delete: deleteBrand,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default BrandService;
|
export default BrandService;
|
Loading…
x
Reference in New Issue
Block a user