Returning nested rows
Opened this issue · 2 comments
Is it possible to return nested JSON values on queries. For example lets say we have two tables named category and post which are connected together using a FOREIGN KEY. we can use a JOIN in a query and have them in flat rows. but is there a solution to have like an array of posts in each category row to have the posts of that category or vice versa, like having a JSON containing posts. with a nested JSON containing category information?
Thanks in advance,
@manafzar is there a possibility to do that in mysql SQL code? If you can write query that returns nested data from mysql I'm sure that it can be read by mysql2 driver.
@manafzar only thing this library does is what described here: https://github.com/mysqljs/mysql/#joins-with-overlapping-column-names
maybe you can achieve desired behaviour using custom typeCast
handler. Would you be able to prepare simple self contained example to demonstrate what you want ( including schema creation in population )?