Reputation: 1
I'm having some issues constructing some functions using postgrest for my senior capstone.
to my understanding the following should work to delete a category connected to a supabase database. (In this context a category is an object with a name and an arraylist of items. items in turn are objects with an ID number, name, price, categoryId and organizationID)
override suspend fun deleteCategory(id: Int) {
withContext(Dispatchers.IO)
{
postgrest["category"]
.delete
{
eq("id", id)
}
.execute()
}
}
however execute is being thrown as a unresolved reference
as well for the update of a category name to my understanding this should work
override suspend fun updateCategory(name: String) {
withContext(Dispatchers.IO) {
postgrest["category"]
.update()
.set("name", name)
.execute()
}
}
But set is being thrown as an unresolved reference as well.
Any help in resolving this would be appreciated.
Also if this is not a good way to achieve what i'm trying to do, please let me know. Always eager to learn how to do these better and easier.
Upvotes: 0
Views: 98
Reputation: 18690
If you look at the documentation, you will notice that there is no .execute()
call on the Kotlin library for Supabase.
https://supabase.com/docs/reference/kotlin/delete
You should be able to delete your data with code something like this:
supabase.from("category").delete {
filter {
eq("id", id)
}
}
Upvotes: 0