Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 使用sql查询的私有字段_Node.js_Sails.js_Waterline - Fatal编程技术网

Node.js 使用sql查询的私有字段

Node.js 使用sql查询的私有字段,node.js,sails.js,waterline,Node.js,Sails.js,Waterline,我最近更改了对SQL数据库的查询 Model.findOne().populate("Model2").exec(function(err, result) { }) 致: 我更改查询的原因是性能问题:使用第二种方法比第一种方法(当您连接表时)快得多 我的问题是:使用Waterline语法,我只能检索我想要的元素(在模型中定义的元素),但是使用查询方法(“Select*from model…”)会向数据库提供我要求的结果,但我希望能够过滤在模型中定义的字段。有可能吗 您的模型定义位于sai

我最近更改了对SQL数据库的查询

Model.findOne().populate("Model2").exec(function(err, result) {
})  
致:

我更改查询的原因是性能问题:使用第二种方法比第一种方法(当您连接表时)快得多


我的问题是:使用Waterline语法,我只能检索我想要的元素(在模型中定义的元素),但是使用查询方法(“Select*from model…”)会向数据库提供我要求的结果,但我希望能够过滤在模型中定义的字段。有可能吗

您的模型定义位于
sails.models.model
对象上

您可以在那里引用可用的属性

Object.keys(sails.models.MODEL._attributes).join(',')
Object.keys(sails.models.MODEL._attributes).join(',')