# Category

We can take the user structure as a reference 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 <mark style="color:blue;">`findOne()`</mark> method, which may make sense as a business rule. Also, in the <mark style="color:blue;">`remove()`</mark> method, make sure there are no related products.

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

<mark style="color:green;">**Commit**</mark> - Implementing category logic and prohibiting exclusions that cause orphans


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://kinesis-school-of-programming.gitbook.io/nestjs-unleashed/core-module-backend-development-with-nestjs/remaining-domain/logic/category.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
