Kotlin: Fetch data

Perform a SELECT query on the table or view.

Parameters

Examples

Getting your data

val city = supabase.from("cities").select().decodeSingle<City>()

Selecting specific columns

val city = supabase.from("cities").select(columns = Columns.list("id, name")).decodeSingle<City>()

Query foreign tables

val columns = Columns.raw("""
    id,
    name,
    cities (
      id,
      name
    )
""".trimIndent())
val country = supabase.from("countries")
  .select(
    columns = columns
  )
  .decodeSingle<Country>()

Query the same foreign table multiple times

val columns = Columns.raw("""
    content,
    from: sender_id(name),
    to: receiver_id(name)
""".trimIndent())
val message = supabase.from("messages")
    .select(columns = columns)
    .decodeSingle<Message>()

Querying with count option

val count = supabase.from("countries")
    .select \{
        count(Count.EXACT)
    \}
    .count()!!

Querying JSON data

val columns = Columns.raw("""
    id, name
    address->city
""".trimIndent())
val user = supabase.from("users")
    .select(columns = columns)
    .decodeSingle<User>()