For a many-to-many relationship between two tables, I have a 3rd join-table that contains extra data.
lists <> lists_items_rel <> items
The lists_items_rel
join-table contains the two IDs to join the two tables and an additionnal column added_by
.
list_id: uint8
item_id: uint8
added_by: uuid
Querying the database using the documentation with this code :
const { data, error } = await this.supabaseService.getClient()
.from('lists')
.select('id, items(*)')
.eq('id', listId);
returns all the correct data but without the added_by
column :
[
{
"id": 2,
"name": "apple",
"unit": "pieces",
"quantity": 2,
"created_at": "2024-08-11T15:59:25.294356+00:00",
"created_by": "dba7e125-61f8-4bf6-bc25-f6fe6d3b92b0"
// "added_by": "dba7e125-61f8-4bf6-bc25-f6fe6d3b92b0" <- this is missing
}
]
What can I add to this code to also include the additional data in the column lists_items_rel.added_by
?