I ran into this problem in different contexts and languages, and I always managed to get around this, but I would like to finally find the right template for this. This is due to joining SQL tables. Usually I made two calls: one for elements and one for comments, but I know that there is a way to get all this in one call, and then smooth out the result.
What I would like to do is take an array that looks like this:
[ { itemId: 1, comments: { commentId: 1 } }, { itemId: 1, comments: { commentId: 2 } }, { itemId: 2, comments: { commentId: 3 } } ]
And include it in this:
[ { itemId: 1, comments: [ { commentId: 1 }, { commentId: 2 } ] }, { itemId: 2, comments: [ { commentId: 3 } ] } ]
user2458067
source share