API/api.medcify.app/models/medicines.js

45 lines
1.3 KiB
JavaScript
Raw Normal View History

2022-09-26 06:11:44 +00:00
'use strict';
const {
Model
} = require('sequelize');
module.exports = (sequelize, DataTypes) => {
class medicines 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)
{
// Joint Query
models.company.hasOne(models.medicines);
models.store.hasOne(models.medicines);
models.medicines.hasOne(models.cart);
models.medicines.hasOne(models.orderDetails);
//For Medicine Table
models.medicineuses.belongsTo(models.medicines);
models.medicinesideeffects.belongsTo(models.medicines);
models.company.hasMany(models.medicines);
}
}
medicines.init({
name: DataTypes.STRING,
companyId: DataTypes.INTEGER,
storeId: DataTypes.INTEGER,
quantity: DataTypes.STRING,
amount: DataTypes.INTEGER,
discount: DataTypes.INTEGER,
image: DataTypes.STRING,
howWorks: DataTypes.STRING,
directionOfUse: DataTypes.STRING,
prescription: DataTypes.INTEGER,
status: DataTypes.INTEGER,
createdBy: DataTypes.INTEGER,
updatedBy: DataTypes.INTEGER
}, {
sequelize,
modelName: 'medicines',
});
return medicines;
};