Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/37.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
Javascript 如何在sails.js中找到一个列的所有寄存器_Javascript_Node.js_Sails.js - Fatal编程技术网

Javascript 如何在sails.js中找到一个列的所有寄存器

Javascript 如何在sails.js中找到一个列的所有寄存器,javascript,node.js,sails.js,Javascript,Node.js,Sails.js,如何查找sails中一列的所有寄存器 我的模型是: models/Blog.js module.exports = { schema: true, attributes: { title:'string', content:{ type:'string', required: true } } }; module.exports = { index: functio

如何查找sails中一列的所有寄存器

我的模型是:

models/Blog.js

module.exports = {
    schema: true,
    attributes: {
        title:'string',
        content:{
            type:'string',
            required: true
        }
    }
};
module.exports = {

    index: function (req, res) {

        Blog.find()
        .exec(function (err, content) {
          if (err) {
            res.send(400);
          } else {
            res.view({OnlyContent:content}); // Only view all Content ?
          }
        });

    },
_config: {}
};
我的控制器: 控制器/BlogController.js

module.exports = {
    schema: true,
    attributes: {
        title:'string',
        content:{
            type:'string',
            required: true
        }
    }
};
module.exports = {

    index: function (req, res) {

        Blog.find()
        .exec(function (err, content) {
          if (err) {
            res.send(400);
          } else {
            res.view({OnlyContent:content}); // Only view all Content ?
          }
        });

    },
_config: {}
};
要仅向客户机发送内容数据,您需要遍历返回的博客数组并过滤掉内容

如果你是这么想的话,目前水线(帆ORM)中没有“选择”功能。但只要稍加研究,您就可以找到许多创造性的方法,使用Javascript从对象数组中提取一个字段。玩得高兴