Я пытаюсь экспортировать данные из html-формы с помощью sequelize и получаю следующую ошибку: Невозможно прочитать свойство 'create' из неопределенного.Я могу вывести данные в объект из формы просто отлично.
rout.js
var db = require("../models");
module.exports = function(app) {
app.post("/api/orders", function(req,res) {
console.log(req.body);
db.orders.create({
date: req.body.date,
billingAddress: req.body.billingAddress,
city: req.body.city,
state: req.body.state,
email: req.body.email,
cupcakeType: req.body.cupcakeType,
quantity: req.body.quantity,
specialInstructions: req.body.specialInstructions,
totalPrice: req.body.totalPrice,
card: req.body.card,
cardNumber: req.body.cardNumber,
cvc: req.body.cvc,
CustomerID: req.body.CustomerID
})
.then(function(dbOrders){
console.log(dbOrders);
res.json(dbOrders);
});
});
orders.js
module.exports = function(sequelize, DataTypes) {
var Orders = sequelize.define("Orders", {
date: {
type: DataTypes.DATEONLY,
allowNull: false
},
billingAddress: {
type: DataTypes.STRING,
allowNull: false,
},
city: {
type: DataTypes.STRING,
allowNull: false,
},
state: {
type: DataTypes.STRING,
allowNull: false,
},
email: {
type: DataTypes.STRING,
allowNull: false,
// validate: {
// isEmail: true
// }
},
Ожидается создание записи в БД с именем 'cupcakes' и таблицей с именем 'orders'