mirror of https://github.com/AMT-Cheif/drift.git
Clarify supported view columns
This commit is contained in:
parent
b8b372f7c7
commit
a4dc3a3305
|
@ -294,9 +294,16 @@ abstract class CategoryTodoCount extends View {
|
||||||
|
|
||||||
Inside a Dart view, use
|
Inside a Dart view, use
|
||||||
|
|
||||||
- abstract getters to declare tables that you'll read from (e.g. `TodosTable get todos`)
|
- abstract getters to declare tables that you'll read from (e.g. `TodosTable get todos`).
|
||||||
- `Expression` getters to add columns: (e.g. `itemCount => todos.id.count()`);
|
- `Expression` getters to add columns: (e.g. `itemCount => todos.id.count()`).
|
||||||
- the overridden `as` method to define the select statement backing the view
|
- the overridden `as` method to define the select statement backing the view.
|
||||||
|
The columns referenced in `select` may refer to two kinds of columns:
|
||||||
|
- Columns defined on the view itself (like `itemCount` in the example above).
|
||||||
|
- Columns defined on referenced tables (like `categories.description` in the example).
|
||||||
|
For these references, advanced drift features like [type converters]({{ '../Advanced Features/type_converters.md' | pageUrl }})
|
||||||
|
used in the column's definition from the table are also applied to the view's column.
|
||||||
|
|
||||||
|
Both kind of columns will be added to the data class for the view when selected.
|
||||||
|
|
||||||
Finally, a view needs to be added to a database or accessor by including it in the
|
Finally, a view needs to be added to a database or accessor by including it in the
|
||||||
`views` parameter:
|
`views` parameter:
|
||||||
|
|
Loading…
Reference in New Issue