NodeJS/Knex Creating Json Response

橙三吉。 提交于 2019-12-02 03:45:18

SQL responses are flat tables by their nature so in addition to knex you will need an external lib which can reconstruct flat information to nested objects.

Most of the ORM libraries know how to do it. For example objection.js which is built on top of knex uses .eager() to fetch nested relations. With objection.js ORM the query would look like this Project.query().where('id', 1).eager('employees')

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!