小编ari*_*mcm的帖子

水线,尝试创建一对多关联时出错

我有这些模型:

// Material.js

module.exports = {
attributes: {

    name: {
        type: 'string',
        required: true
    },
    source_info: {
        type: 'string',
        required: true
    },
    category: { model: 'category_mat' }
}
};
Run Code Online (Sandbox Code Playgroud)

和:

// Category_Mat.js

module.exports = {
attributes: {
    name: {
      type: 'string',
      required: true
    },
    material:{
        collection: 'material',
        via: 'category'
    }
},
};
Run Code Online (Sandbox Code Playgroud)

但是当我运行应用程序时,我收到此错误:

/usr/local/lib/node_modules/sails/node_modules/waterline/node_modules/waterline-schema/lib/waterline-schema/foreignKeys.js:82
throw new Error('Trying to access a collection ' + collection + ' that is 
      ^

Error: Trying to access a collection category_mat that is not defined. …
Run Code Online (Sandbox Code Playgroud)

sails.js waterline

6
推荐指数
1
解决办法
1506
查看次数

Sequelize,如何从连接表中检索特定字段

我有:

db.Animal.findAll({ attributes: ['id', 'name'], include: [db.Age] }).success(function(results) {
    console.log(JSON.stringify(results));
});
Run Code Online (Sandbox Code Playgroud)

它从表Animal中给我字段ID和NAME ...但我也想从表Age中获取特定字段而不是所有字段(这就是它现在的工作方式).

我能做什么?

node.js express sequelize.js

4
推荐指数
1
解决办法
3801
查看次数

标签 统计

express ×1

node.js ×1

sails.js ×1

sequelize.js ×1

waterline ×1