docID and depID Added

This commit is contained in:
Jyotirmoy Bandyopadhayaya 2020-10-28 22:03:44 +05:30
parent fc29fe19df
commit 8ae3f11003
8 changed files with 108 additions and 98 deletions

View File

@ -7,7 +7,7 @@ define({
"apidoc": "0.3.0",
"generator": {
"name": "apidoc",
"time": "2020-10-28T09:54:02.061Z",
"time": "2020-10-28T13:41:36.256Z",
"url": "http://apidocjs.com",
"version": "0.20.1"
}

View File

@ -7,7 +7,7 @@
"apidoc": "0.3.0",
"generator": {
"name": "apidoc",
"time": "2020-10-28T09:54:02.061Z",
"time": "2020-10-28T13:41:36.256Z",
"url": "http://apidocjs.com",
"version": "0.20.1"
}

View File

@ -9,12 +9,12 @@ const router = new Router();
const {
No,
PatientName,
DocterName,
docID,
Email,
PhoneNo,
Date,
Time,
Department,
depID,
Msg,
Age,
} = schema.tree;
@ -40,12 +40,12 @@ router.post(
body({
No,
PatientName,
DocterName,
docID,
Email,
PhoneNo,
Date,
Time,
Department,
depID,
Msg,
Age,
}),
@ -94,12 +94,12 @@ router.put(
body({
No,
PatientName,
DocterName,
docID,
Email,
PhoneNo,
Date,
Time,
Department,
depID,
Msg,
Age,
}),

View File

@ -8,8 +8,8 @@ const apointmentSchema = new Schema(
PatientName: {
type: String,
},
DocterName: {
type: String,
docID: {
type: Number,
},
Email: {
type: String,
@ -23,8 +23,8 @@ const apointmentSchema = new Schema(
Time: {
type: String,
},
Department: {
type: String,
depID: {
type: Number,
},
Msg: {
type: String,
@ -51,14 +51,14 @@ apointmentSchema.methods = {
id: this.id,
No: this.No,
PatientName: this.PatientName,
DocterName: this.DocterName,
docID: this.docID,
Email: this.Email,
PhoneNo: this.PhoneNo,
Date: this.Date,
Time: this.Time,
Msg: this.Msg,
Age: this.Age,
Department: this.Department,
depID: this.depID,
createdAt: this.createdAt,
updatedAt: this.updatedAt,
};

View File

@ -1,13 +1,13 @@
import { Router } from 'express'
import { middleware as query } from 'querymen'
import { middleware as body } from 'bodymen'
import { token } from '../../services/passport'
import { create, index, show, update, destroy } from './controller'
import { schema } from './model'
export Department, { schema } from './model'
import { Router } from "express";
import { middleware as query } from "querymen";
import { middleware as body } from "bodymen";
import { token } from "../../services/passport";
import { create, index, show, update, destroy } from "./controller";
import { schema } from "./model";
export Department, { schema } from "./model";
const router = new Router()
const { ID, Name, Nos } = schema.tree
const router = new Router();
const { depID, Name, Nos } = schema.tree;
/**
* @api {post} /Departments Create department
@ -23,10 +23,12 @@ const { ID, Name, Nos } = schema.tree
* @apiError 404 Department not found.
* @apiError 401 admin access only.
*/
router.post('/',
token({ required: true, roles: ['admin'] }),
body({ ID, Name, Nos }),
create)
router.post(
"/",
token({ required: true, roles: ["admin"] }),
body({ depID, Name, Nos }),
create
);
/**
* @api {get} /Departments Retrieve departments
@ -37,9 +39,7 @@ router.post('/',
* @apiSuccess {Object[]} rows List of departments.
* @apiError {Object} 400 Some parameters may contain invalid values.
*/
router.get('/',
query(),
index)
router.get("/", query(), index);
/**
* @api {get} /Departments/:id Retrieve department
@ -49,8 +49,7 @@ router.get('/',
* @apiError {Object} 400 Some parameters may contain invalid values.
* @apiError 404 Department not found.
*/
router.get('/:id',
show)
router.get("/:id", show);
/**
* @api {put} /Departments/:id Update department
@ -63,9 +62,7 @@ router.get('/:id',
* @apiError {Object} 400 Some parameters may contain invalid values.
* @apiError 404 Department not found.
*/
router.put('/:id',
body({ ID, Name, Nos }),
update)
router.put("/:id", body({ depID, Name, Nos }), update);
/**
* @api {delete} /Departments/:id Delete department
@ -74,7 +71,6 @@ router.put('/:id',
* @apiSuccess (Success 204) 204 No Content.
* @apiError 404 Department not found.
*/
router.delete('/:id',
destroy)
router.delete("/:id", destroy);
export default router
export default router;

View File

@ -1,43 +1,50 @@
import mongoose, { Schema } from 'mongoose'
import mongoose, { Schema } from "mongoose";
const departmentSchema = new Schema({
ID: {
type: String
const departmentSchema = new Schema(
{
depID: {
type: String,
},
Name: {
type: String,
},
Nos: {
type: String,
},
},
Name: {
type: String
},
Nos: {
type: String
{
timestamps: true,
toJSON: {
virtuals: true,
transform: (obj, ret) => {
delete ret._id;
},
},
}
}, {
timestamps: true,
toJSON: {
virtuals: true,
transform: (obj, ret) => { delete ret._id }
}
})
);
departmentSchema.methods = {
view (full) {
view(full) {
const view = {
// simple view
id: this.id,
ID: this.ID,
depID: this.depID,
Name: this.Name,
Nos: this.Nos,
createdAt: this.createdAt,
updatedAt: this.updatedAt
}
updatedAt: this.updatedAt,
};
return full ? {
...view
// add properties for a full view
} : view
}
}
return full
? {
...view,
// add properties for a full view
}
: view;
},
};
const model = mongoose.model('Department', departmentSchema)
const model = mongoose.model("Department", departmentSchema);
export const schema = model.schema
export default model
export const schema = model.schema;
export default model;

View File

@ -7,7 +7,7 @@ import { schema } from "./model";
export Doctor, { schema } from "./model";
const router = new Router();
const { ID, Name, Dapartment } = schema.tree;
const { docID, Name, Dapartment } = schema.tree;
/**
* @api {post} /Doctors Create doctor
@ -69,7 +69,7 @@ router.get("/:id", show);
router.put(
"/:id",
token({ required: true, roles: ["admin"] }),
body({ ID, Name, Dapartment }),
body({ docID, Name, Dapartment }),
update
);

View File

@ -1,43 +1,50 @@
import mongoose, { Schema } from 'mongoose'
import mongoose, { Schema } from "mongoose";
const doctorSchema = new Schema({
ID: {
type: String
const doctorSchema = new Schema(
{
docID: {
type: String,
},
Name: {
type: String,
},
Dapartment: {
type: String,
},
},
Name: {
type: String
},
Dapartment: {
type: String
{
timestamps: true,
toJSON: {
virtuals: true,
transform: (obj, ret) => {
delete ret._id;
},
},
}
}, {
timestamps: true,
toJSON: {
virtuals: true,
transform: (obj, ret) => { delete ret._id }
}
})
);
doctorSchema.methods = {
view (full) {
view(full) {
const view = {
// simple view
id: this.id,
ID: this.ID,
docID: this.docID,
Name: this.Name,
Dapartment: this.Dapartment,
createdAt: this.createdAt,
updatedAt: this.updatedAt
}
updatedAt: this.updatedAt,
};
return full ? {
...view
// add properties for a full view
} : view
}
}
return full
? {
...view,
// add properties for a full view
}
: view;
},
};
const model = mongoose.model('Doctor', doctorSchema)
const model = mongoose.model("Doctor", doctorSchema);
export const schema = model.schema
export default model
export const schema = model.schema;
export default model;