addColumns method
Adds a custom expression to the query.
The database will evaluate the Expression for each row found for this query. The value of the expression can be extracted from the TypedResult by passing it to TypedResult.read.
As an example, we could calculate the length of a column on the database:
final contentLength = todos.content.length;
final results = await select(todos).addColumns([contentLength]).get();
// we can now read the result of a column added to addColumns
final lengthOfFirst = results.first.read(contentLength);
See also:
- The docs on expressions: https://drift.simonbinder.eu/docs/getting-started/expressions/
Implementation
JoinedSelectStatement addColumns(List<Expression> expressions) {
return join([])..addColumns(expressions);
}