OxL Reference

kw where

Contextual keyword — generic constraints, refinements, the for filter, queries

The list of words: §1.4

Syntax

ebnf
Where       = "where" WClause { "," WClause } ;
ebnf
TypeAlias   = "type" Ident [ Generics ] "=" ( [ "distinct" ] Type [ "where" Expr ] ) ;
ebnf
For         = [ Label ":" ] [ "inline" ] "for" [ "await" ] Pattern "in" Expr [ "where" Expr ] Block ;
ebnf
Query       = "from" Pattern "in" Expr { "where" Expr } [ "order" "by" Ord { "," Ord } ]
              [ "group" "by" Expr "into" Ident ] [ "skip" Expr ] [ "take" Expr ]
              [ "load" "(" IdentList ")" ] [ "select" Expr ] ;

Grammar: App. A

Defined in

Examples

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())

— 5.9 Query expressions

oxl
type Bytes2 = [u8; 2]                     // alias, the same type
type UserId = distinct u64                // a new type, no implicit conversions
type Port   = u16 where 1..=65535         // refined type
type Name   = str where len(1..=64)
type Email  = str where matches(re".+@.+\..+")

— 3.6 Aliases, new types and refined types

Related diagnostics

query-not-sql, refinement-violated, bound-not-satisfied, generic-args, break-value, outside-loop, arg-count, named-arg

See also