B:BD[
5.647] → [
5.647:881]
json_agg(distinct jsonb_build_object(
'id', product.id,
'name', product.display_name,
'type', product.type,
'strain', product.strain,
'brand', product.display_brand
)) as products
(
select json_agg(item) from (
select
product.id,
product.display_name as name,
product.type,
product.strain,
product.display_brand as brand
from
product
left outer join variant on product.id = variant.product
inner join menu_item on menu_item.variant = variant.id
where
menu_item.store = store.id
) as item
) as products