Hi all, just picked up Supabase for a project and ...
# help
e
Hi all, just picked up Supabase for a project and I have a noob question ––  I have a table
conversations
with column
participants
of type JSONB (originally JSON but I think it needs to be JSONB) where the structure is something like:
Copy code
[
  "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:
Copy code
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"
n
Hello @evanw! This thread has been automatically created from your message in #843999948717555735 a ``few seconds ago``. Pinging @User so that they see this as well! Want to unsubscribe from this thread? Right-click the thread in Discord (or use the ... menu) and select Leave Thread to unsubscribe from future updates. Want to change the title? Use the
/title
command! We have solved your problem? Click the button below to archive it.
g
The contains would work if you had created the column as text array type.
n
evan (2022-04-18)
g
e
Thank you! The text array is working great now. I'll eventually be making
participants
an array of objects, like
[{ name: 'Emily', id: 123 }, ...]
so this looks like it might work better there.