Given this tables:
BOOKS
id | data
----+-------------------------------------------------------
1 | { title: 'Book 1', price: 10.5, authors: [{ id: 1}, { id: 2 }]}
2 | { title: 'Book 2', price: 11.5, authors: [{ id: 2 } }
AUTHORS
id | data
-----+-------------------------------------------------------
1 | { name: 'Author 1', address: 'Address author 1' }
2 | { name: 'Author 2', address: 'Address author 2' }
Is it possible to obtain this result, by merging the authors key array elements, with a JOIN-like statement or using jsonb functions?
BOOKS QUERY RESULT
id | data
----+------------------------------------------------------------------------------------------------------
1 | { title: 'Book 1', price: 10.5, authors: [{ id: 1, name: 'Author 1', address: 'Address author 1' }, { id: 2, name: 'Author 2', address: 'Address author 2'}] }
2 | { title: 'Book 2', price: 11.5, authors: [{ id: 2, name: 'Author 2', address: 'Address author 2'}] }
Thanks