Manager API: orderBy expression #3425
-
With the Core API, we can use expressions in the orderBy clauses: final query = select(db.todos) //
..orderBy([(t) => OrderingTerm.asc(t.name.lower())]); Is there any plan to support expressions with the Manager API (beyond basic "column expressions")? For example: database.managers.todos //
..orderBy((t) => t.name.lower().asc()) Or is there currently an official way to use expressions with the Manager API? For now, we can write something like that: database.managers.todos //
.orderBy((t) => ColumnOrderings(database.todos.name.lower()).asc()) But I don't think it's philosophically OK with the Manager API (to use the table directly without using the provided OrderingComposer). I didn't tested but as It will create an |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
The manager API was kept very simple, maybe too simple. However, you can do what your describing using a computed field. // First create an computed field with an expression you want to use
final lowerCaseName = db.managers.todos.computedField((o) => o.name.lower());
// Then use it
db.managers.todos.withFields([lowerCaseName]).orderBy((_) => lowerCaseName.orderings.asc()) |
Beta Was this translation helpful? Give feedback.
-
It will be hard to get the
|
Beta Was this translation helpful? Give feedback.
The manager API was kept very simple, maybe too simple.
However, you can do what your describing using a computed field.