Skip to content

Commit 17fc461

Browse files
committed
Update pure data
1 parent c6c6269 commit 17fc461

2 files changed

Lines changed: 12 additions & 4 deletions

File tree

i18n/en/docusaurus-plugin-content-docs/current/guides/examples/entity-layer.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -514,15 +514,19 @@ export const formatDate = (date: Date) =>
514514

515515
### Pure Data Loading Without Logic
516516

517+
If fetching data is all that happens — no filtering, no aggregation, no business rules applied to the result — there's no reason to introduce `model/`. The key criterion is the absence of business logic, not the tool used to fetch.
518+
517519
```typescript
518-
// A query library already handles state and caching.
519-
// An API function is sufficient — no entity model needed.
520+
// No business logic here — just loading and displaying.
521+
// An API function is sufficient, model/ is not needed.
520522
const { data: users } = useQuery({
521523
queryKey: ['users'],
522524
queryFn: getUsers,
523525
})
524526
```
525527

528+
Once you find yourself deriving, filtering, or combining that data based on domain rules, that's when model/ earns its place.
529+
526530
### A Single Computed Value
527531

528532
```typescript

i18n/ru/docusaurus-plugin-content-docs/current/guides/examples/entity-layer.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -507,15 +507,19 @@ export const formatDate = (date: Date) =>
507507

508508
### Просто загрузка данных без логики
509509

510+
Если всё что происходит — это загрузка и отображение данных, без фильтрации, агрегации и применения бизнес-правил к результату, вводить `model/` незачем. Ключевой критерий — отсутствие бизнес-логики, а не инструмент для запросов.
511+
510512
```typescript
511-
// Библиотека запросов уже управляет состоянием и кешированием.
512-
// API-функции достаточно — model/ в entities не нужна.
513+
// Бизнес-логики нет — только загрузка и отображение.
514+
// Достаточно API-функции, model/ не нужна.
513515
const { data: users } = useQuery({
514516
queryKey: ['users'],
515517
queryFn: getUsers,
516518
})
517519
```
518520

521+
Как только вы начинаете фильтровать, комбинировать или преобразовывать эти данные по доменным правилам — вот тогда model/ оправдана.
522+
519523
### Одиночное вычисляемое значение
520524

521525
```typescript

0 commit comments

Comments
 (0)