evanw
04/18/2022, 1:01 PMconversations
with column participants
of type JSONB (originally JSON but I think it needs to be JSONB) where the structure is something like:
[
"Emily",
"Renee",
"Martina"
]
I'm trying to return an array of all conversations
where participants
includes the current user, e.g. "Emily".
This is what I've tried, but I'm certain this is wrong:
let { data, error, status } = await supabase
.from('conversations')
.select('id, name, participants')
.contains('participants', ['Emily']);
Any pointers? Or should my data be structured differently? (Future state, participants
might be more like [ { name: 'Emily', id: 123 } ]
but for right now I'm just trying to sorta learn the basics
The error I'm getting with this is "invalid input syntax for type json"Needle
04/18/2022, 1:01 PM/title
command!
We have solved your problem?
Click the button below to archive it.garyaustin
04/18/2022, 1:03 PMNeedle
04/18/2022, 1:03 PMgaryaustin
04/18/2022, 1:07 PMevanw
04/18/2022, 1:21 PMparticipants
an array of objects, like [{ name: 'Emily', id: 123 }, ...]
so this looks like it might work better there.