I have a recipes table with columns recipe_id, product_name, instructions and I have instructions table with columns recipe_id, instructions.
columns instructions and recipe_id in recipes table is the same number that points to instructions table.
I was using supabase client and tried to join them like this:
let { data, error, count } = await supabase
.from('recipes')
.select(
`*,
instructions(instructions)
`,
{ count: 'exact' }
)
.eq('id', id);
But the returned data had instructions as an object:
Recipes table:
| recipe_id | instructions | product_name |
|-----------|--------------|--------------|
| 24 | 24 | omelette |
Instructions table
| recipe_id | instructions |
|-----------|--------------------------------------------------|
| 24 | '{"root":{"children":[{"children":[{"detail":0,"for…format":"","indent":0,"type":"root","version":1}}' |
I want combine it so it looks like this:
product_name: "Omelette",
recipe_id: 24,
instructions: '{"root":{"children":[{"children":[{"detail":0,"for…format":"","indent":0,"type":"root","version":1}}'
How can I write a function that joins recipe with instructions and returns it as a key instead of another object?
Something that I could call it with supabase.rpc()
