我有这些模型:
// 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) 我有:
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中获取特定字段而不是所有字段(这就是它现在的工作方式).
我能做什么?