Nice Explanation Adhi, Just want to Add support for custom where clauses:
async destroy(data, whereClause = {}) {
const response = await this.model.destroy({
where: {
id: data,
...whereClause,
},
});
if (!response) {
throw new AppError('Not able to find the resource', StatusCodes.NOT_FOUND);
}
return response;
}
This allows users to specify additional conditions for deletion besides the primary key.
Nice Explanation Adhi, Just want to Add support for custom where clauses:
async destroy(data, whereClause = {}) { const response = await this.model.destroy({ where: { id: data, ...whereClause, }, }); if (!response) { throw new AppError('Not able to find the resource', StatusCodes.NOT_FOUND); } return response; }
This allows users to specify additional conditions for deletion besides the primary key.