30325/backend/src/db/models/hospitals.js
2025-03-30 02:51:01 +00:00

78 lines
1.4 KiB
JavaScript

const config = require('../../config');
const providers = config.providers;
const crypto = require('crypto');
const bcrypt = require('bcrypt');
const moment = require('moment');
module.exports = function (sequelize, DataTypes) {
const hospitals = sequelize.define(
'hospitals',
{
id: {
type: DataTypes.UUID,
defaultValue: DataTypes.UUIDV4,
primaryKey: true,
},
name: {
type: DataTypes.TEXT,
},
address: {
type: DataTypes.TEXT,
},
city: {
type: DataTypes.TEXT,
},
state: {
type: DataTypes.TEXT,
},
zip_code: {
type: DataTypes.TEXT,
},
phone_number: {
type: DataTypes.TEXT,
},
wait_time: {
type: DataTypes.DECIMAL,
},
last_updated: {
type: DataTypes.DATE,
},
importHash: {
type: DataTypes.STRING(255),
allowNull: true,
unique: true,
},
},
{
timestamps: true,
paranoid: true,
freezeTableName: true,
},
);
hospitals.associate = (db) => {
/// loop through entities and it's fields, and if ref === current e[name] and create relation has many on parent entity
//end loop
db.hospitals.belongsTo(db.users, {
as: 'createdBy',
});
db.hospitals.belongsTo(db.users, {
as: 'updatedBy',
});
};
return hospitals;
};