From a4dc3a3305a0281e40f88ce4a268079911ae18f5 Mon Sep 17 00:00:00 2001 From: Simon Binder Date: Mon, 23 May 2022 21:38:23 +0200 Subject: [PATCH] Clarify supported view columns --- .../docs/Getting started/advanced_dart_tables.md | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/docs/pages/docs/Getting started/advanced_dart_tables.md b/docs/pages/docs/Getting started/advanced_dart_tables.md index d7dfb4a9..fcbf053d 100644 --- a/docs/pages/docs/Getting started/advanced_dart_tables.md +++ b/docs/pages/docs/Getting started/advanced_dart_tables.md @@ -294,9 +294,16 @@ abstract class CategoryTodoCount extends View { Inside a Dart view, use -- 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()`); -- the overridden `as` method to define the select statement backing the view +- 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()`). +- 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 `views` parameter: