zql ! {
dbs::create( #app_db, {
namespace: "bf91cccb-81ca-4ebe-9687-a79d7d3debb2"
} )
}
zql ! {
destroy dbs.#app_db
}
zql ! {
let persons = table::create( #persons, {
name: string validate [ is_uppercase] ,
age: int,
} )
}
zql ! {
destroy table.#persons
}
zql ! {
let color = enums::create( #color, [
#red,
#green,
#blue,
] )
}
zql ! {
destroy enums.#color
}
zql ! {
let person = types::create( #person, {
name: string validate [ is_uppercase] ,
age: int,
} )
}
zql ! {
destroy types.#person
}
zql ! {
persons::add( #john, {
name: "John Doe" ,
age: 42 ,
} )
}
zql ! {
persons.#john.update( {
age: 43 ,
} )
}
zql ! {
remove persons.#john
}
zql ! {
let red = color.#red
}
zql ! {
[ { name } in persons ]
}
zql ! {
[ p in persons, p.age > 18 ]
}
zql ! {
[ { name: p.name, age: p.age } : p in persons, p.age > 18 ]
}
Uniform Function Call Syntax
zql ! {
[ { name: uppercase( p.name) } : p in persons ]
[ { name: p.name.uppercase( ) } : p in persons ]
}
zql ! {
[ { name: uppercase( p.name) } : p in persons ]
[ { name: uppercase p.name } : p in persons ]
}
zql ! {
[ { age: mod ( p.age, 18 ) } : p in persons ]
[ { name: p.age mod 18 } : p in persons ]
}
zql ! {
[ { name: .name.uppercase( ) } in persons, 18 ..20 contains .age ]
}
zql ! {
[ { name: .name.uppercase( ) } in persons, 18 ..20 contains .age ] |> order asc |> group_by #age |> limit 10
}
zql ! {
transaction {
persons::add( #john, {
name: "John Doe" ,
age: 42 ,
} )
persons.#john.update( {
age: 43 ,
} )
remove persons.#john
}
}
zql ! {
[ { age: .age + 1 } in persons ]
}
zql ! {
[ { age: .age - 1 } in persons ]
}
zql ! {
[ { age: .age * 2 } in persons ]
}
zql ! {
[ { age: .age / 2 } in persons ]
}
zql ! {
[ { age: .age % 2 } in persons ]
}
zql ! {
[ { age: .age ^ 2 } in persons ]
}
zql ! {
persons.#john -> friend -> persons.#jane
}
zql ! {
persons.#john -/> friend -/> persons.#jane
}
zql ! {
[ { name } in persons.#john -> friend -> * ]
[ { name } in * -> friend -> persons.#jane ]
[ { name } in * -> friend -> * ]
[ { name } in * -> friend ]
[ { name } in friend -> * ]
}
123
+ 123
- 123
123_ u32
123.0
123.0e-2
123.0_ f64
123.0e-2_ f64
123.
.123
0b11001
0b11001 _u32
0xabcf
0xabcf_f64
0o1274
0o1274 _u16
"Hello World"
'Hello World'
{
name: "John Doe" ,
age: 42 ,
}
#james
#0xf356bc
#`😏j37386vSG)=`
zql ! {
{
let x = 1 ;
let y = 2 ;
x + y
}
}
zql ! {
function average( s: [ int] ) -> [ int] {
// ...
}
}
zql ! {
|p| p.age > 18
|p| {
p.age > 18
}
}
zql ! {
let age = [ { age } in persons ] |> first
match age {
18 => "adult" ,
0 ..=17 => "child" ,
}
}
zql ! {
function sum( s: [ int] ) -> [ int] {
match s {
[ ] => 0 ,
[ x] => x,
[ x, ..xs] => x + sum( xs) ,
}
}
}
#[ zql:: import]
fn average ( s : IntStream ) -> Int {
// ...
}
zql ! {
import average
[ { age } in persons ] |> average
}