David
David
DTDrizzle Team
Created by David on 12/7/2024 in #help
How to use subqueries with query
No description
9 replies
DTDrizzle Team
Created by David on 12/5/2024 in #help
Smart way to prepare data for frontend
As you can imagine, query returns aren't exacly pretty, and they'll have rows for each value that matches. For example, let's say you want to grab posts and comments. On your select, you'd have a row (or in drizzle case, an object for each row) for each post and comment. something like
[{postId:"1",commentId:"1",text:""},{postId:"1",commentId:"2",text:""}]
[{postId:"1",commentId:"1",text:""},{postId:"1",commentId:"2",text:""}]
Is there a way (without scripting on the js side), to map certain keys to a schema you want to have? In this scenario I'd like to have something like
[{postId:"1",comments:[{id:1, text:""},{id:2,text:""}]]
[{postId:"1",comments:[{id:1, text:""},{id:2,text:""}]]
This is just a simple example, let me know if my explanation wasn't clear enough.
11 replies