add limit example

This commit is contained in:
Christopher Boumenot 2020-04-22 19:55:13 -07:00
parent 87ae54bad0
commit 2c4d17af82
1 changed files with 6 additions and 0 deletions

View File

@ -47,6 +47,12 @@ details on expressions, see [this guide]({{< relref "expressions.md" >}}).
### Limit ### Limit
You can limit the amount of results returned by calling `limit` on queries. The method accepts You can limit the amount of results returned by calling `limit` on queries. The method accepts
the amount of rows to return and an optional offset. the amount of rows to return and an optional offset.
```dart
Future<List<Todo>> limitTodos(int limit, {int offset}) {
return (select(todos)..limit(limit, offset: offset)).get();
}
```
### Ordering ### Ordering
You can use the `orderBy` method on the select statement. It expects a list of functions that extract the individual You can use the `orderBy` method on the select statement. It expects a list of functions that extract the individual
ordering terms from the table. ordering terms from the table.