栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

Node.js-将SQL查询转换为Knex.js

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Node.js-将SQL查询转换为Knex.js

要调试,您可以

.toSQL()
用来调试knex查询文档。
另外,漂亮的速查表

作为热修复解决方案,您可以在其中使用

.raw()
并粘贴SQL代码。

关于

WHERe
条件,您可以将它们链接在knex查询的末尾。
像这样的东西:

return knex('user')  .select('user.id', 'user.name', 'user.email',     'role.name AS rName'    'user_profile.id AS pId', 'user_profile.date_of_birth AS pDob',     'auth_token.id AS atId' 'auth_token.platform AS atPlatform', 'auth_token.token AS atToken'   )  .leftJoin('user_profile', 'user_profile.user_id', 'user.id')  .leftJoin('user_role', 'user_role.user_id', 'user.id')  .leftJoin('role', 'role.id', 'user_role.role_id')  .leftJoin('auth_token', 'auth_token.user_id', 'user.id')   .where('user.email', 'like', '%some@email.com%')  .andWhere('application.name', 'like' '%awesome-application%')//...etc


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/386285.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号