我在我的sails.js應用程序中使用sails-hook-sequelize和sails-hook-sequelize-blueprints。Sequelize HasMany不工作
我有一個模型叫做Site
。
module.exports = {
attributes: {
id: {
type: Sequelize.INTEGER,
primaryKey: true,
autoIncrement: true
},
name: {
type: Sequelize.STRING,
required: true
}
},
associations: function() {
Site.hasMany(Templates, {
as: 'templates'
});
}
};
每個網站都有多個關聯的Templates
。
module.exports = {
attributes: {
id: {
type: Sequelize.INTEGER,
primaryKey: true,
autoIncrement: true
},
name: {
type: Sequelize.STRING,
required: true
}
}
};
我得到一個錯誤說
/user/myproject/node_modules/sails-hook-sequelize-blueprints/index.js:362
var alias = foreign.as || foreign.name || foreign;
^
TypeError: Cannot read property 'as' of undefined
任何想法可能是什麼呢?