mirror of
https://github.com/ent/ent.git
synced 2026-05-22 09:31:45 +03:00
Reviewed By: alexsn Differential Revision: D17113889 fbshipit-source-id: edf4d9af9660fe31e0d02f58a65bcbc4d549a695
37 lines
492 B
Markdown
Executable File
37 lines
492 B
Markdown
Executable File
---
|
|
id: paging
|
|
title: Paging And Ordering
|
|
---
|
|
|
|
## Limit
|
|
|
|
`Limit` limits the query result to `n` entities.
|
|
|
|
```go
|
|
users, err := client.User.
|
|
Query().
|
|
Limit(n).
|
|
All(ctx)
|
|
```
|
|
|
|
|
|
## Offset
|
|
|
|
`Offset` sets the first vertex to return from the query.
|
|
|
|
```go
|
|
users, err := client.User.
|
|
Query().
|
|
Offset(10).
|
|
All(ctx)
|
|
```
|
|
|
|
## Ordering
|
|
|
|
`Order` returns the entities sorted by the values of one or more fields.
|
|
|
|
```go
|
|
users, err := client.User.Query().
|
|
Order(ent.Asc(user.FieldName)).
|
|
All(ctx)
|
|
``` |