can anyone help me with querying many to many relation tables in postgres?
i have tables:
> 1.exercise(id,name)
> 2.tag(id,label)
> 3.tag_in_exercise(id,exercise_id,tag_id)
let say, that we have one exercise bonded with two tags via tag_in_exercise
when using query :
select e.id,t.label from exercise e
left join tag_in_exercise te on e.id=te.exercise_id
left join tag t on te.tag_id=t.id
i will receive json
[ { id: 1,
label: 'basic1' },
{ id: 1,
label: 'basic2' }]
but i want to receive it as nested json
[ { id: 1,
tags:[ {'basic1'},{'basic2'} ]
}]
is it possible to get that by using standart postgresql queries or i need to use some ORM?
or if exists another solution please let me know,
thanks