Querying a specific key and value in an array

I have a table "users" with a column "friends" that is of the type jsonb[]. Like this:
[
  {
    name: "maria",
    email: "maria@mail.pt"
  },
  {
    name: "john",
    email: "john@mail.pt"
  },
  {
    name: "paola",
    email: "paola@mail.pt"
  },
]

I want to fetch the users that have a friend with, for example, "john@mail.pt" as email.

  const {data, error} = await supabase
    .from('users')
    // only the "users" that have a friend with "john@mail.pt"
Was this page helpful?