mirror of https://github.com/AMT-Cheif/drift.git
Re-run build in moor_flutter/example, index in moor files
This commit is contained in:
parent
1b60879a09
commit
2ae6fbc99b
|
@ -42,6 +42,9 @@ CREATE TABLE categories (
|
|||
description TEXT NOT NULL
|
||||
) AS Category; -- the AS xyz after the table defines the data class name
|
||||
|
||||
-- You can also create an index or triggers with moor files
|
||||
CREATE INDEX categories_description ON categories(description);
|
||||
|
||||
-- we can put named sql queries in here as well:
|
||||
createEntry: INSERT INTO todos (title, content) VALUES (:title, :content);
|
||||
deleteById: DELETE FROM todos WHERE id = :id;
|
||||
|
@ -184,11 +187,12 @@ At the moment, the following statements can appear in a `.moor` file.
|
|||
|
||||
- `import 'other.moor'`: Import all tables and queries declared in the other file
|
||||
into the current file.
|
||||
- DDL statements (`CREATE TABLE`): Declares a table. We don't currently support indices and views,
|
||||
[#162](https://github.com/simolus3/moor/issues/162) tracks support for that.
|
||||
- DDL statements: You can put `CREATE TABLE`, `CREATE INDEX` and `CREATE TRIGGER` statements
|
||||
into moor files. Views are not currently supported, but [#162](https://github.com/simolus3/moor/issues/162)
|
||||
tracks support for them.
|
||||
- Query statements: We support `INSERT`, `SELECT`, `UPDATE` and `DELETE` statements.
|
||||
|
||||
All imports must come before DDL statements, and those must come before the named queries.
|
||||
All imports must come before DDL statements, and those must come before named queries.
|
||||
|
||||
If you need support for another statement, or if moor rejects a query you think is valid, please
|
||||
create an issue!
|
|
@ -428,21 +428,13 @@ abstract class _$Database extends GeneratedDatabase {
|
|||
);
|
||||
}
|
||||
|
||||
Selectable<CategoriesWithCountResult> _categoriesWithCountQuery() {
|
||||
Selectable<CategoriesWithCountResult> _categoriesWithCount() {
|
||||
return customSelectQuery(
|
||||
'SELECT\n c.id,\n c.desc,\n (SELECT COUNT(*) FROM todos WHERE category = c.id) AS amount\n FROM categories c\n UNION ALL\n SELECT null, null, (SELECT COUNT(*) FROM todos WHERE category IS NULL)',
|
||||
variables: [],
|
||||
readsFrom: {categories, todos}).map(_rowToCategoriesWithCountResult);
|
||||
}
|
||||
|
||||
Future<List<CategoriesWithCountResult>> _categoriesWithCount() {
|
||||
return _categoriesWithCountQuery().get();
|
||||
}
|
||||
|
||||
Stream<List<CategoriesWithCountResult>> _watchCategoriesWithCount() {
|
||||
return _categoriesWithCountQuery().watch();
|
||||
}
|
||||
|
||||
@override
|
||||
Iterable<TableInfo> get allTables => allSchemaEntities.whereType<TableInfo>();
|
||||
@override
|
||||
|
|
Loading…
Reference in New Issue