Store_UI/admin/distz/api/models/order.js
2022-09-26 11:48:12 +05:30

43 lines
1.2 KiB
JavaScript

'use strict';
const {
Model
} = require('sequelize');
const orderdetails = require('./orderdetails');
module.exports = (sequelize, DataTypes) => {
class order extends Model {
/**
* Helper method for defining associations.
* This method is not a part of Sequelize lifecycle.
* The `models/index` file will call this method automatically.
*/
static associate(models) {
// define association here
models.orderDetails.belongsTo(models.order);
models.order.hasOne(models.store);
models.order.hasOne(models.users);
models.order.hasOne(models.orderProcess);
models.order.hasOne(models.medicines);
}
}
order.init({
date: DataTypes.DATE,
userId: DataTypes.INTEGER,
storeId: DataTypes.INTEGER,
prescriptionId: DataTypes.INTEGER,
deviceId: DataTypes.STRING,
quantity: DataTypes.INTEGER,
amount: DataTypes.DOUBLE,
discount: DataTypes.DOUBLE,
total: DataTypes.DOUBLE,
paymentMethod: DataTypes.INTEGER,
orderProcessId: DataTypes.INTEGER,
status: DataTypes.INTEGER,
createdBy: DataTypes.INTEGER,
updatedBy: DataTypes.INTEGER
}, {
sequelize,
modelName: 'order',
});
return order;
};