Create database functions that return nested objects for relations

I want to create a database function that, when called, will return nested values, eg.
{ name: 'milk', categories: [ { name: 'food' }, { name: 'fridge' } ] }

So the above has milk as the primary table and then it has categories as nested values being passed back.
Was this page helpful?