mirror of https://github.com/AMT-Cheif/drift.git
Add `all()` extension to load all rows
This commit is contained in:
parent
592a96bf7e
commit
ba2a0280d3
|
@ -2,6 +2,7 @@
|
|||
|
||||
- Add `isExp`, `isValue`, `isNotExp` and `isNotValue` methods to `Expression`
|
||||
to generate the `IS` operator in SQL.
|
||||
- Add `all()` extension on tables and views to quickly query all rows.
|
||||
|
||||
## 2.4.2
|
||||
|
||||
|
|
|
@ -4,6 +4,14 @@ import 'package:drift/drift.dart';
|
|||
/// tables or views.
|
||||
extension TableOrViewStatements<Tbl extends HasResultSet, Row>
|
||||
on ResultSetImplementation<Tbl, Row> {
|
||||
/// Selects all rows that are in this table.
|
||||
///
|
||||
/// The returned [Selectable] can be run once as a future with [Selectable.get]
|
||||
/// or as an auto-updating stream with [Selectable.watch].
|
||||
Selectable<Row> all() {
|
||||
return select();
|
||||
}
|
||||
|
||||
/// Composes a `SELECT` statement on the captured table or view.
|
||||
///
|
||||
/// This is equivalent to calling [DatabaseConnectionUser.select].
|
||||
|
|
|
@ -43,4 +43,11 @@ void main() {
|
|||
const TodoWithCategoryViewData(
|
||||
description: 'category description', title: 'title'));
|
||||
});
|
||||
|
||||
test('all()', () async {
|
||||
final user = await db.users.insertReturning(
|
||||
UsersCompanion.insert(name: 'Test user', profilePicture: Uint8List(0)));
|
||||
|
||||
expect(await db.users.all().get(), [user]);
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue