0
retrieveCart関数を呼び出すときにこのエラーが発生しますか? find allのクエリのエラーは何ですか?私はproductIDという名前の外部キーをcartProductsテーブルに自動的に続けることで作成しましたか?未処理の拒否TypeError:sequalize
Unhandled rejection TypeError: Cannot read property 'getTableName' of undefined
const Product = db.define('products', {
id: {
type: Sequelize.INTEGER,
primaryKey: true,
autoIncrement: true
},
name: Sequelize.STRING,
price: Sequelize.INTEGER,
pic: Sequelize.STRING
});
const Cart = db.define('cartProduct',{
cid: {
type: Sequelize.INTEGER,
primaryKey: true,
autoIncrement: true
},
qty:{
type:Sequelize.INTEGER,
defaultValue:1
}
});
Product.sync({}).then(()=>{
Cart.belongsTo(Product);
Cart.sync({});
Product.destroy({
where:{}
});
Cart.destroy({
where:{}
});
console.log("DataBase Created");
var i ,len = products.length;
for(i=0;i<len;i++){
Product.create({
id:i+1,
name: products[i].name,
price: products[i].price,
pic: products[i].img
}).then(()=>{
console.log("Data Inserted");
});
}
});
function retrieveCart() {
return Cart.findAll({
include:[{
modal:Product,
attributes:['name','price']}]
})
}