I have a Supabase project where I use a PostgreSQL database. One of my columns is called tags, and I store an array of strings in the JSONB type. I input a word and want to find a row that contains an array with that word, and for that, I use the .contains() function. However, when I write .contains(“tags”, input.toList) (input is the incoming string), I get an error:
BadRequestException:invalid input syntax for type json (Token “tags” is invalid).
Please, help me to create function, to find arrays in columns, that contains not only one input word, but list of them
(sorry, for my English)
My attemp
suspend fun getFormsByTags(tagsToFind: String): List<FormDto>{
val result = supabase
.from(SUPABASE_NAME_KEY)
.select() {
filter {
contains("tags", listOf(tagsToFind))
}
}
return result.decodeList()
}
@Serializable
data class FormDto(
@SerialName("title")
val title: String,
@SerialName("description")
val description: String,
@SerialName("tags")
val tags: List<String>
)
0
Sorry, I found the answer. It was necessary to replace the column type with text and then everything worked like a charm! 🙂