sails.js - 如何在sails js中使用填充子标准(例如:.populate('something',{select:[]}))
问题描述
.populate('something',{select:[]})) in sails js .
对我来说,这是一个模棱两可的用法。是否有任何替代解决方案
我在填充中使用了 select ...但它显示子标准在这个版本的风帆中不起作用
Banktransaction.find(newData).populate('project_id',{select:['project_name']}).exec((err,banktrans)=>{
if(err){
return res.json({
error : err
});
}
if(!banktrans){
return res.notFound();
}else{
return res.json({
'responseType':"success",
'responseMessage':"Banktransaction details founded successfully",
'result': banktrans
});
}
});
//result
{
"error": {
"name": "UsageError",
"code": "E_INVALID_POPULATES",
"details": "Could not populate `project_id` because of ambiguous usage. This is a singular (\"model\") association, which means it never refers to more than _one_ associated record. So passing in subcriteria (i.e. as the second argument to `.populate()`) is not supported for this association, since it generally wouldn't make any sense. But that's the trouble-- it looks like some sort of a subcriteria (or something) _was_ provided!\n(Note that subcriterias consisting ONLY of `omit` or `select` are a special case that _does_ make sense. This usage will be supported in a future version of Waterline.)\n\nHere's what was passed in:\n{ select: [ 'project_name' ] }"
}
}
解决方案
推荐阅读
- javascript - HTML逐列而不是逐行添加数据
- javascript - 引导弹出框焦点不起作用
- excel - 用于填充工作表上特定表格的用户表单数据
- node.js - Node.js 中多线程加密的好资源?
- java - Spring / JPA 加入命名空间键
- sql - 是否可以在 PostgreSQL 中加入 CTE?
- java - Angularjs $http.get 在 Firefox 新版本中不起作用
- java - 文本视图在 DP 中具有相同的宽度设置,但看起来不同
- visual-studio - Visual Studio 想要 Ninja Generator,即使我没有安装它
- php - 数组中的唯一键