SupabaseS
Supabase3y ago
kirk

how to get single item in join query

I have a query below that gets the items associated with a list.
  return client
    .from(LISTS_TABLE)
    .select(
      `
        id,
        name,
        listItems: list_items!list_id (
        status
      )
      `,
    )
    .eq('id', id)
    .single();


But let's say that list_items has a 1 to 1 relationship with lists. how can I modify the query to get a single item from the list_items table? The code above works, but it will return an array of list items when i want it to just be the object because it is a 1 to 1 relationship.
Was this page helpful?