Category

We can base ourselves on the user structure to compose the category one. So, we can copy and paste the contents of both user's CreateDTO and Service files to the corresponding category's files, and after that adjust where necessary.

The CTRL + F hotkey can be used to quickly swap words, for example when copying service's contents, swap user for category. The option Preserve Case may also be helpful.

Let's load the related products in the findOne() method, which may make sense as a business rule. Also, in the remove() method, make sure there are no related products.

if (category.products.length) {
  throw new ConflictException('Category has related products');
}

Commit - Implementing category logic and prohibiting exclusions that cause orphans

Last updated