【发布时间】:2018-05-03 18:13:53
【问题描述】:
我的前端查询:
http://localhost:8888/api/employees?access_token=adsafsaf&filter={%22where%22:{%22emp_code%22:%22EMPT01%22}}
原始 where 查询:{"where":{"emp_code":"EMPT01"}}
我正在尝试在上面的传入请求中动态添加 "code" 字段。
Employee.observe('access', function (ctx, next) {
// first way, it is not adding "orgId" field.
ctx.query.where = {
orgId: ctx.options.data.orgId
};
// second way, it is not adding "orgId" field.
const query = {};
query['orgId'] = ctx.options.data.orgId;
ctx.query.where = query;
next();
});
请高人指点一下,哪里错了?
环回版本:3
谢谢
【问题讨论】:
-
ctx.options.data在获取请求中来自哪里?我已经在没有它的情况下测试了你的代码并且它正在工作。此外,您没有添加到查询中,而是替换它。 -
ctx.options.data : 它来自中间件。
-
尝试发布您的连接器调试字符串。 loopback.io/doc/en/lb3/Setting-debug-strings.html
标签: loopbackjs strongloop