Skip to content

Commit d0debc3

Browse files
committed
chore: add example for defaultSort in relations
1 parent 2b68b2e commit d0debc3

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

documentation/docs/graphql/dtos.mdx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,15 @@ export class TodoItemDTO {
650650
```
651651
652652
:::info
653-
When we use the `@FilterableRelation` decorator or other [relation decorators](./relations.mdx) you might want to define the default sorting criteria since its default value is `[]`, meaning if you do **not** specify it you will receive the results as your underlying database decided to return it which makes it unreliable.
653+
When we use the `@Relation` decorator or other [relation decorators](./relations.mdx) you might want to define the default sorting criteria like this:
654+
```ts title="todo-item.dto.ts"
655+
import { SortDirection } from '@ptc-org/nestjs-query-core';
656+
// ...
657+
@Relation('assignee', () => UserDTO, {
658+
defaultSort: [{ field: 'id', direction: SortDirection.ASC }],
659+
})
660+
```
661+
Note that default value for `defaultSort` is `[]`, meaning if you do **not** specify it you will receive the results as your underlying database decided to return it which makes it unreliable.
654662
:::
655663
656664
### Allowed Boolean Expressions

0 commit comments

Comments
 (0)