Node.js 水线填充和不工作的位置
当您执行Node.js 水线填充和不工作的位置,node.js,sails.js,waterline,Node.js,Sails.js,Waterline,当您执行Model.populate('project',{where:{org\u id:['15']}})时 应该返回正确的记录,但实际上返回的记录与该记录不匹配。我必须假设这是在吃水线处断裂的 使用postgresql适配器 我的代码: if (query.org_id) { console.log(criteria); console.log(query.org_id); org_criteria = module.exports.conv
Model.populate('project',{where:{org\u id:['15']}})时
应该返回正确的记录,但实际上返回的记录与该记录不匹配。我必须假设这是在吃水线处断裂的
使用postgresql适配器
我的代码:
if (query.org_id) {
console.log(criteria);
console.log(query.org_id);
org_criteria = module.exports.convert_string_to_array_selector(query.org_id, 'org_id');
console.log(org_criteria);
base_query = base_query.populate('project_id', {
where: {
org_id: org_criteria
}
});
}
我也尝试过这种语法:base\u query=base\u query.populate('project\u id',{org\u id:org\u criteria});
我的日志:
{ where: { state: 'ACTIVE' }, limit: 20, skip: 0 }
17
[ '17' ]
{ where: { state: 'ACTIVE' },
limit: 20,
skip: 0,
joins:
[ { parent: 'external_resource',
parentKey: 'project_id',
child: 'project',
childKey: 'id',
select: [Object],
alias: 'project_id',
removeParentKey: true,
model: true,
collection: false,
criteria: [Object] } ] }
Found Files: { project_id:
{ id: '7',
name: 'Nike2 Inc. People',
description: 'the people',
created_by: 'user1',
org_id: '5',
is_private: true,
is_user_default_project: false,
is_org_default: false,
type: 'PROJECT',
is_template: false,
color: 'rgb(223,115,255)',
state: 'ACTIVE',
createdAt: '2017-05-18T13:22:21.565Z',
updatedAt: null },
note_id: '6',
id: '3',
external_id: '070a00c03bcd11e7b0e19deb0847dfce.png',
version_id: null,
url: '/apps/intellinote/files/projects/7/070a27d03bcd11e7b0e19deb0847dfce',
name: 'small.png',
size: '220',
creator: 'user1',
type: 'FILE',
is_public: true,
state: 'ACTIVE',
mime_type: 'image/png',
internal_type: 'REGULAR',
is_template: false,
has_filled_data: false,
createdAt: '2017-05-18T16:22:23.000Z',
updatedAt: '2017-05-18T16:22:23.000Z' }
请注意,该查询在项目上的组织id为17,但找到的记录的组织id为5。这在今天的sails中不起作用。它只过滤子对象,不过滤父对象。需要自定义查询。这是一个左联接,将返回任何匹配项