API/api.medcify.app/models/order.js
2022-09-26 11:41:44 +05:30

46 lines
1.3 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.prescription);
models.order.hasOne(models.users);
models.order.hasOne(models.orderProcess);
//models.order.hasOne(models.medicines);
//models.order.hasOne(models.orderDetails);
}
}
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,
deliveryfee: 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;
};