Professional Documents
Culture Documents
function* rootSaga() {
yield all([
fetchPatients(),
createPatients(),
deletePatient(),
updatePatient(),
fetchPatientById(),
fetchDoctors(),
createDoctors(),
deleteDoctor(),
updateDoctors(),
fetchDoctorById(),
]);
}
appointment controller -
const models = require("../models/index");
module.exports = { createAppointment }
--------------------------------------------------------------
Appointment.js from models -
"use strict";
const { Model } = require("sequelize");
module.exports = (sequelize, DataTypes) => {
class Appointments extends Model {
static associate(models) {
Appointments.belongsTo(models.Patients, { foreignKey: "patientId" });
Appointments.belongsTo(models.Doctors, { foreignKey: "doctorId" });
}
}
Appointments.init(
{
appointmentsId: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true,
},
patientId: {
type: DataTypes.INTEGER,
allowNull: false,
},
doctorId: {
type: DataTypes.INTEGER,
allowNull: false,
},
description: {
type: DataTypes.STRING,
allowNull: false,
},
disease: {
type: DataTypes.STRING,
allowNull: false,
},
},
{
sequelize,
modelName: "Appointments",
tableName: "Appointments",
timestamps: true,
}
);
return Appointments;
};