Archived
1
0
Fork 0
This repository has been archived on 2024-02-17. You can view files and clone it, but cannot push or open issues or pull requests.
kfet/models/command.js

65 lines
1.4 KiB
JavaScript

"use strict";
module.exports = (sequelize, DataTypes) => {
const Command = sequelize.define('Command', {
number: {
type: DataTypes.INTEGER,
allowNull: false,
unique: "uniqueNumberPerDay"
},
price: {
type: DataTypes.FLOAT,
allowNull: false
},
date: {
type: DataTypes.DATEONLY,
defaultValue: DataTypes.NOW,
allowNull: false,
unique: "uniqueNumberPerDay"
},
take: {
type: DataTypes.DATE,
defaultValue: DataTypes.NOW,
allowNull: false
},
done: {
type: DataTypes.DATE
},
give: {
type: DataTypes.DATE
},
WIP: {
type: DataTypes.BOOLEAN,
defaultValue: false,
allowNull: false
},
error: {
type: DataTypes.BOOLEAN,
defaultValue: false,
allowNull: false
}
}, {
tableName: "Commands"
});
Command.associate = function(models) {
// associations can be defined here
Command.belongsTo(models.User, {
as: "client"
});
Command.belongsTo(models.User, {
as: "pc"
});
Command.belongsTo(models.User, {
as: "sandwich"
});
Command.belongsTo(models.Dish);
Command.belongsToMany(models.Ingredient, {
through: "CommandsIngredients"
});
Command.belongsToMany(models.Sauce, {
through: "CommandsSauces"
});
Command.belongsTo(models.Drink);
Command.belongsTo(models.Dessert);
};
return Command;
};