OxL Reference

5.9 Query expressions

oxl
let top = from o in db.Order
  where o.userId == uid && o.total > MIN_TOTAL
  order by o.createdAt desc
  skip page * PAGE_SIZE
  take PAGE_SIZE
  load(items)

let names = from u in users where u.active select u.name   // in-memory List
let byRole = from u in users group by u.role into g select (g.key, g.count())
  • Form: from x in source (where e)* (order by e (asc|desc)?, …)? (group by e into g)? (skip e)? (take e)? (load(field, …))? (select e)?.
  • Source Table<T> (§12.8): the query is compiled to SQL at build time and executed with the db effect; the result is List<T> (or List<S> with select). Expressions in where/order by MUST be translatable to SQL: fields, literals, parameters, arithmetic, comparisons, in, && || !, starts_with, contains, lower; otherwise — a compile error.
  • Any other source Iterable<T>: the query is evaluated in memory and returns iter<T> (lazy).

query-not-sql

See also

Source: docs/spec/oxl-standard.en.md