o1lab/xmysql

XJOIN to generate object tree

lixaotec opened this issue · 3 comments

Dear fellows,

Is it possible to handle xjoin to generate object json tree instead of single level with properties being renamed by their aliases?

I think that option would be very handful to simulate traditional ORM behaviors.

How hard would be this change?

Thanks

o1lab commented

@lixaotec If I understand this correctly, by object json tree you mean nested json - this is not possible with current implementation.

Dear @o1lab ,

Thats correct. You got my point!

I made progress by implementing a view and used json_object() function in order to convert the nested part to json. The issue now is that the lib always converts the result to json by itself leading to a escaped json at the nested part.

I think of two paths,

  1. raw view results - adjusting the response of view for a 'raw' , that i could handle all the json conversion at mysql view functionls (also leads to xmysql lib changes)

  2. handle json type - adjust the lib to ignore json type column at the conversion point.

What do you think?

I´m looking for these paths as the xjoins mess with columns name for the correct returning, and I look forward to have a similar as possible behavior to a object model.

Thank you again.

o1lab commented

Please leave an example of table(s) structure, sql query, xjoin query and expected outcome. Will look into this in future if possible.