Add docs on how to evaluate expressions

This commit is contained in:
Simon Binder 2022-02-25 12:45:00 +01:00
parent ba8d719f2c
commit 4755d0d04e
No known key found for this signature in database
GPG Key ID: 7891917E4147B8C0
1 changed files with 14 additions and 0 deletions

View File

@ -13,6 +13,20 @@ abstract class FunctionParameter implements Component {}
/// include queries (which might evaluate to multiple values) but individual
/// columns, functions and operators.
///
/// To obtain the result of an [Expression], add it as a result column to a
/// [JoinedSelectStatement], e.g. through [DatabaseConnectionUser.selectOnly]:
///
/// ```dart
/// Expression<int?> countUsers = users.id.count();
///
/// // Add the expression to a select statement to evaluate it.
/// final query = selectOnly(users)..addColumns([countUsers]);
/// final row = await query.getSingle();
///
/// // Use .read() on a row to read expressions.
/// final amountOfUsers = query.read(counUsers);
/// ```
///
/// It's important that all subclasses properly implement [hashCode] and
/// [==].
abstract class Expression<D> implements FunctionParameter {