Retrieval
Synchronous Retrieval
databaseForTable<Employee> { db ->
// list
val employees = (select from Employee::class).queryList(db)
// single result, we apply a limit(1) automatically to get the result even faster.
val employee: Employee? = (select from Employee::class
where Employee_Table.name.eq("Andrew Grosner")).querySingle(db)
// can require result to get non-null if you know it exists
// throws a SQLiteException if missing
val employee: Employee? = (select from Employee::class
where Employee_Table.name.eq("Andrew Grosner")).requireSingle(db)
// get a custom list
val employees: List<AnotherTable> = (select from Employee::class)
.queryCustomList(database)
// custom object
val anotherObject: AnotherTable? = (select from Employee::class
where(Employee_Table.name.eq("Andrew Grosner")))
.queryCustomSingle()
// require custom object
val anotherObject: AnotherTable = (select from Employee::class
where(Employee_Table.name.eq("Andrew Grosner")))
.requireCustomSingle()
}Asynchronous Retrieval
Last updated
Was this helpful?