Data
Drizzle
A typed query builder, checked by the compiler.
Drizzle is a TypeScript query builder. The Kotlin equivalent is a typed query DSL over your entities: conditions use property references, so a typo or a wrong type is a compile error, and values are always bound as parameters (never concatenated into SQL).
import io.kest.orm.*
val rows = orders.query {
where((Order::status eq "open") and (Order::total gt 100L) and (Order::sku startsWith "A-"))
orderBy(Order::createdAt.desc())
limit(50)
}
val first = orders.queryOne { where(Order::email eq email) }
val open = orders.queryCount { where(Order::status eq "open") }
val page = orders.queryPage(PageRequest.of(1, 20)) { where(Order::status eq "open") } // Page<Order>
val slice = orders.querySlice(PageRequest.of(1, 20)) { where(Order::customerId within ids) } // Slice<Order>| Operator | |
|---|---|
eq, ne, gt, ge, lt, le | comparisons (eq null becomes IS NULL) |
like, contains, startsWith, endsWith | text matching (wildcards in the input are escaped for contains/startsWith/endsWith) |
within, notWithin, between | sets and ranges |
isNull(), isNotNull() | |
and, or | combine; use parentheses for grouping |
Works on PostgreSQL, MySQL and MongoDB with the same code.
Not built: joins and projections in the DSL (use relations, @Query or native SQL for those) and a schema-as-code definition: entities stay annotated Kotlin classes, from which the processor generates the mapping at build time.