dependencies {
implementation platform("io.github.ferhatwi:supabase-kt-bom:{BOM_VERSION}")
implementation "io.github.ferhatwi:supabase-database-kt"
}
dependencies {
implementation "io.github.ferhatwi:supabase-database-kt:{DATABASE_VERSION}"
}
Supabase should be initialized before using this library. Instructions are here.
val db = Supabase.database()
db.rpc.request<List<SomeDataClass>>(
schema = SCHEMA,
function = FUNCTION,
selections = listOf(SELECTION, SELECTION2),
count = COUNT,
filters = listOf(FILTER, FILTER2),
orders = listOf(ORDER, ORDER2),
range = FROM to TO,
data = DATA
).catch {
}.collect {
}
db.get.request<List<SomeDataClass>>(
schema = SCHEMA,
table = FUNCTION,
selections = listOf(SELECTION, SELECTION2),
count = COUNT,
filters = listOf(FILTER, FILTER2),
orders = listOf(ORDER, ORDER2),
range = FROM to TO
).catch {
}.collect {
}
db.delete.request<List<SomeDataClass>>(
schema = SCHEMA,
table = FUNCTION,
selections = listOf(SELECTION, SELECTION2),
count = COUNT,
filters = listOf(FILTER, FILTER2),
orders = listOf(ORDER, ORDER2),
range = FROM to TO
).catch {
}.collect {
}
db.update.request<List<SomeDataClass>>(
schema = SCHEMA,
table = FUNCTION,
selections = listOf(SELECTION, SELECTION2),
count = COUNT,
filters = listOf(FILTER, FILTER2),
orders = listOf(ORDER, ORDER2),
range = FROM to TO,
data = DATA,
).catch {
}.collect {
}
db.insert.request<List<SomeDataClass>>(
schema = SCHEMA,
table = FUNCTION,
selections = listOf(SELECTION, SELECTION2),
count = COUNT,
orders = listOf(ORDER, ORDER2),
range = FROM to TO,
data = DATA
).catch {
}.collect {
}
db.upsert.request<List<SomeDataClass>>(
schema = SCHEMA,
table = FUNCTION,
selections = listOf(SELECTION, SELECTION2),
count = COUNT,
orders = listOf(ORDER, ORDER2),
range = FROM to TO,
data = DATA
).catch {
}.collect {
}
db.listen.request<List<SomeDataClass>>(
schema = SCHEMA,
table = FUNCTION,
events = listOf(Event.INSERT, Event.UPDATE, Event.DELETE),
filter = Filter.EqualTo(COLUMN, VALUE)
).cancellable()
.catch {
}
.collect {
}
Feel free to improve, upgrade, fix or report bugs!