db

Generated by tinox doc

tinox.core.db, split out of the bundled stdlib as a standalone tinox-central package.

Entity crud

import tinox.core.db

@Entity
@Table("customers")
class Customer
{
    @Id
    @GeneratedValue
    var id: Int64

    var name: String
    var email: String
}

Entity crud entry point

import Customer
import tinox.core.db

// Every Tinox program still needs its own class Main as the mandatory
// entry point (since 2026-08-09) -- this is the required sibling file
// for the @Entity class above (one type per file, since 2026-07-26).
class Main
{
    fnc main() -> Int32
    {
        const customers: List<Customer> = DB::of(Customer).list()

        const customer: Customer = DB::of(Customer).filter(c => c.id == 1).first()
        println(customer.name)

        const active: List<Customer> = DB::of(Customer).orderBy(c => c.name).limit(10).list()

        DB::of(Customer).save(customer)
        DB::of(Customer).delete(customer)

        return 0
    }
}

class DB

Methods

fnc of(cls: Any) → Any
fnc raw(sql: String, params: List<String>) → List<Map<String, String>>

class EntityQuery

Methods

fn filter(predicate: fnc(Any) -> Bool) → Any
fn orderBy(field: fnc(Any) -> Any) → Any
fn orderByDesc(field: fnc(Any) -> Any) → Any
fn limit(n: Int64) → Any
fn offset(n: Int64) → Any
fn list() → Any
fn first() → Any
fn count() → Int64
fn save(entity: Any) → Any
fn delete(entity: Any) → Nothing
fn saveAll(entities: Any) → Nothing