Getting results in document form rather than record

Hi, new to drizzle but liking it so far. Is there away to get the results in more of a 'document' structure? For example, I'd like to get {id: 1, user: "joe", posts: [{id : 1, title: "my first post"},{id : 2, title: "my second post"}]} rather than in record form [{id: 1, user: "joe", post: {id : 1, title: "my first post"}}, ...}]. I'm doing something like select({id ... post: {id: posts.id, title, posts.title}}). Thanks.
2 Replies
Dan
Dan2y ago
Currently, you need to map it manually - https://github.com/drizzle-team/drizzle-orm/blob/main/docs/joins.md#aggregating-results We have plans for adding a relational query builder to address cases like this in the future.
GitHub
drizzle-orm/joins.md at main · drizzle-team/drizzle-orm
TypeScript ORM for SQL. Contribute to drizzle-team/drizzle-orm development by creating an account on GitHub.
Julio Barros
Julio BarrosOP2y ago
Great. Thank you.
Want results from more Discord servers?
Add your server