javascript - 环回中每个 API 调用中的 Where 子句
问题描述
我想要一种可以添加“where”子句的方法,该子句将在 Get、Update、Delete 的所有 API 调用中都有一个 Id。
我正在使用中间件来实现这一点。下面是我的代码:
module.exports = function(){
return function parse(req, res, next) {
// Add an 'and' filter that specifies the tenant in all requests.
req.query.filter = ({
where: { tenantCompanyKey: '1a4f7513147aefc2a93ac7153df458fd' }
});
next();
}
}
所以当查询被执行时,它应该看起来像:
SELECT * FROM tbl_accounts
WHERE tenant_company_key = '1a4f7513147aefc2a93ac7153df458fd'
解决方案
推荐阅读
- android - ACCESS_BACKGROUND_LOCATION 不适用于低于 Q (29) 的 Android 版本
- sql - 大数据条件聚合
- mysql - 在 MySQL Azure 中使用角色 - 管理员帐户的权限问题
- google-sheets - Query 是否最适合“调用”多个列并以新顺序显示列?
- swift - 退出应用程序时在 UserDefaults 中存储标签值(日期)
- perl - 如何区分 Template Toolkit for perl 中的假值和定义值
- youtube-api - Youtube api 检测实时视频
- cmake - 错误:未知的 CMake 命令“add_llvm_loadable_module”
- google-app-engine - Google 应用引擎:使用键与使用查询检索实体的成本和效率
- flutter - 如何使用 ProxyProvider 调用异步方法?