{"size": 851, "ext": "js", "max_stars_repo_path": "src/models/index.js", "max_stars_repo_name": "Super-Doctor/server", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/models/index.js", "max_issues_repo_name": "Super-Doctor/server", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/models/index.js", "max_forks_repo_name": "Super-Doctor/server", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 30.3928571429, "max_line_length": 147, "alphanum_fraction": 0.7309048179}
'use strict';


require('dotenv').config();

const {Sequelize , DataTypes} = require('sequelize');

const patientModel = require('./patient-model');
const doctorModel = require('./doctor-model');
const roleModel = require('./roles-model');

const SQL_DATABASE_URL = process.env.SQL_DATABASE_URL || "postgres://gxvtzktj:Z0X7tmh-7pZEdTAwsG1Jd6_VmTXBZJtk@chunee.db.elephantsql.com/gxvtzktj";

const sequelize = new Sequelize (SQL_DATABASE_URL, {});

const patient = patientModel(sequelize , DataTypes);
const doctor = doctorModel(sequelize, DataTypes);
const role = roleModel(sequelize, DataTypes);

// To create the relations
doctor.hasMany(patient, { sourceKey: 'id', foreignKey: 'doctorId' });
patient.belongsTo(doctor, { foreignKey: 'doctorId', targetKey: 'id' });

module.exports = {
    db : sequelize,
    Patient : patient,
    Doctor : doctor
} 