docID and depID Added
This commit is contained in:
parent
fc29fe19df
commit
8ae3f11003
|
@ -7,7 +7,7 @@ define({
|
||||||
"apidoc": "0.3.0",
|
"apidoc": "0.3.0",
|
||||||
"generator": {
|
"generator": {
|
||||||
"name": "apidoc",
|
"name": "apidoc",
|
||||||
"time": "2020-10-28T09:54:02.061Z",
|
"time": "2020-10-28T13:41:36.256Z",
|
||||||
"url": "http://apidocjs.com",
|
"url": "http://apidocjs.com",
|
||||||
"version": "0.20.1"
|
"version": "0.20.1"
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
"apidoc": "0.3.0",
|
"apidoc": "0.3.0",
|
||||||
"generator": {
|
"generator": {
|
||||||
"name": "apidoc",
|
"name": "apidoc",
|
||||||
"time": "2020-10-28T09:54:02.061Z",
|
"time": "2020-10-28T13:41:36.256Z",
|
||||||
"url": "http://apidocjs.com",
|
"url": "http://apidocjs.com",
|
||||||
"version": "0.20.1"
|
"version": "0.20.1"
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,12 +9,12 @@ const router = new Router();
|
||||||
const {
|
const {
|
||||||
No,
|
No,
|
||||||
PatientName,
|
PatientName,
|
||||||
DocterName,
|
docID,
|
||||||
Email,
|
Email,
|
||||||
PhoneNo,
|
PhoneNo,
|
||||||
Date,
|
Date,
|
||||||
Time,
|
Time,
|
||||||
Department,
|
depID,
|
||||||
Msg,
|
Msg,
|
||||||
Age,
|
Age,
|
||||||
} = schema.tree;
|
} = schema.tree;
|
||||||
|
@ -40,12 +40,12 @@ router.post(
|
||||||
body({
|
body({
|
||||||
No,
|
No,
|
||||||
PatientName,
|
PatientName,
|
||||||
DocterName,
|
docID,
|
||||||
Email,
|
Email,
|
||||||
PhoneNo,
|
PhoneNo,
|
||||||
Date,
|
Date,
|
||||||
Time,
|
Time,
|
||||||
Department,
|
depID,
|
||||||
Msg,
|
Msg,
|
||||||
Age,
|
Age,
|
||||||
}),
|
}),
|
||||||
|
@ -94,12 +94,12 @@ router.put(
|
||||||
body({
|
body({
|
||||||
No,
|
No,
|
||||||
PatientName,
|
PatientName,
|
||||||
DocterName,
|
docID,
|
||||||
Email,
|
Email,
|
||||||
PhoneNo,
|
PhoneNo,
|
||||||
Date,
|
Date,
|
||||||
Time,
|
Time,
|
||||||
Department,
|
depID,
|
||||||
Msg,
|
Msg,
|
||||||
Age,
|
Age,
|
||||||
}),
|
}),
|
||||||
|
|
|
@ -8,8 +8,8 @@ const apointmentSchema = new Schema(
|
||||||
PatientName: {
|
PatientName: {
|
||||||
type: String,
|
type: String,
|
||||||
},
|
},
|
||||||
DocterName: {
|
docID: {
|
||||||
type: String,
|
type: Number,
|
||||||
},
|
},
|
||||||
Email: {
|
Email: {
|
||||||
type: String,
|
type: String,
|
||||||
|
@ -23,8 +23,8 @@ const apointmentSchema = new Schema(
|
||||||
Time: {
|
Time: {
|
||||||
type: String,
|
type: String,
|
||||||
},
|
},
|
||||||
Department: {
|
depID: {
|
||||||
type: String,
|
type: Number,
|
||||||
},
|
},
|
||||||
Msg: {
|
Msg: {
|
||||||
type: String,
|
type: String,
|
||||||
|
@ -51,14 +51,14 @@ apointmentSchema.methods = {
|
||||||
id: this.id,
|
id: this.id,
|
||||||
No: this.No,
|
No: this.No,
|
||||||
PatientName: this.PatientName,
|
PatientName: this.PatientName,
|
||||||
DocterName: this.DocterName,
|
docID: this.docID,
|
||||||
Email: this.Email,
|
Email: this.Email,
|
||||||
PhoneNo: this.PhoneNo,
|
PhoneNo: this.PhoneNo,
|
||||||
Date: this.Date,
|
Date: this.Date,
|
||||||
Time: this.Time,
|
Time: this.Time,
|
||||||
Msg: this.Msg,
|
Msg: this.Msg,
|
||||||
Age: this.Age,
|
Age: this.Age,
|
||||||
Department: this.Department,
|
depID: this.depID,
|
||||||
createdAt: this.createdAt,
|
createdAt: this.createdAt,
|
||||||
updatedAt: this.updatedAt,
|
updatedAt: this.updatedAt,
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
import { Router } from 'express'
|
import { Router } from "express";
|
||||||
import { middleware as query } from 'querymen'
|
import { middleware as query } from "querymen";
|
||||||
import { middleware as body } from 'bodymen'
|
import { middleware as body } from "bodymen";
|
||||||
import { token } from '../../services/passport'
|
import { token } from "../../services/passport";
|
||||||
import { create, index, show, update, destroy } from './controller'
|
import { create, index, show, update, destroy } from "./controller";
|
||||||
import { schema } from './model'
|
import { schema } from "./model";
|
||||||
export Department, { schema } from './model'
|
export Department, { schema } from "./model";
|
||||||
|
|
||||||
const router = new Router()
|
const router = new Router();
|
||||||
const { ID, Name, Nos } = schema.tree
|
const { depID, Name, Nos } = schema.tree;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @api {post} /Departments Create department
|
* @api {post} /Departments Create department
|
||||||
|
@ -23,10 +23,12 @@ const { ID, Name, Nos } = schema.tree
|
||||||
* @apiError 404 Department not found.
|
* @apiError 404 Department not found.
|
||||||
* @apiError 401 admin access only.
|
* @apiError 401 admin access only.
|
||||||
*/
|
*/
|
||||||
router.post('/',
|
router.post(
|
||||||
token({ required: true, roles: ['admin'] }),
|
"/",
|
||||||
body({ ID, Name, Nos }),
|
token({ required: true, roles: ["admin"] }),
|
||||||
create)
|
body({ depID, Name, Nos }),
|
||||||
|
create
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @api {get} /Departments Retrieve departments
|
* @api {get} /Departments Retrieve departments
|
||||||
|
@ -37,9 +39,7 @@ router.post('/',
|
||||||
* @apiSuccess {Object[]} rows List of departments.
|
* @apiSuccess {Object[]} rows List of departments.
|
||||||
* @apiError {Object} 400 Some parameters may contain invalid values.
|
* @apiError {Object} 400 Some parameters may contain invalid values.
|
||||||
*/
|
*/
|
||||||
router.get('/',
|
router.get("/", query(), index);
|
||||||
query(),
|
|
||||||
index)
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @api {get} /Departments/:id Retrieve department
|
* @api {get} /Departments/:id Retrieve department
|
||||||
|
@ -49,8 +49,7 @@ router.get('/',
|
||||||
* @apiError {Object} 400 Some parameters may contain invalid values.
|
* @apiError {Object} 400 Some parameters may contain invalid values.
|
||||||
* @apiError 404 Department not found.
|
* @apiError 404 Department not found.
|
||||||
*/
|
*/
|
||||||
router.get('/:id',
|
router.get("/:id", show);
|
||||||
show)
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @api {put} /Departments/:id Update department
|
* @api {put} /Departments/:id Update department
|
||||||
|
@ -63,9 +62,7 @@ router.get('/:id',
|
||||||
* @apiError {Object} 400 Some parameters may contain invalid values.
|
* @apiError {Object} 400 Some parameters may contain invalid values.
|
||||||
* @apiError 404 Department not found.
|
* @apiError 404 Department not found.
|
||||||
*/
|
*/
|
||||||
router.put('/:id',
|
router.put("/:id", body({ depID, Name, Nos }), update);
|
||||||
body({ ID, Name, Nos }),
|
|
||||||
update)
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @api {delete} /Departments/:id Delete department
|
* @api {delete} /Departments/:id Delete department
|
||||||
|
@ -74,7 +71,6 @@ router.put('/:id',
|
||||||
* @apiSuccess (Success 204) 204 No Content.
|
* @apiSuccess (Success 204) 204 No Content.
|
||||||
* @apiError 404 Department not found.
|
* @apiError 404 Department not found.
|
||||||
*/
|
*/
|
||||||
router.delete('/:id',
|
router.delete("/:id", destroy);
|
||||||
destroy)
|
|
||||||
|
|
||||||
export default router
|
export default router;
|
||||||
|
|
|
@ -1,43 +1,50 @@
|
||||||
import mongoose, { Schema } from 'mongoose'
|
import mongoose, { Schema } from "mongoose";
|
||||||
|
|
||||||
const departmentSchema = new Schema({
|
const departmentSchema = new Schema(
|
||||||
ID: {
|
{
|
||||||
type: String
|
depID: {
|
||||||
|
type: String,
|
||||||
|
},
|
||||||
|
Name: {
|
||||||
|
type: String,
|
||||||
|
},
|
||||||
|
Nos: {
|
||||||
|
type: String,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
Name: {
|
{
|
||||||
type: String
|
timestamps: true,
|
||||||
},
|
toJSON: {
|
||||||
Nos: {
|
virtuals: true,
|
||||||
type: String
|
transform: (obj, ret) => {
|
||||||
|
delete ret._id;
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}, {
|
);
|
||||||
timestamps: true,
|
|
||||||
toJSON: {
|
|
||||||
virtuals: true,
|
|
||||||
transform: (obj, ret) => { delete ret._id }
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
departmentSchema.methods = {
|
departmentSchema.methods = {
|
||||||
view (full) {
|
view(full) {
|
||||||
const view = {
|
const view = {
|
||||||
// simple view
|
// simple view
|
||||||
id: this.id,
|
id: this.id,
|
||||||
ID: this.ID,
|
depID: this.depID,
|
||||||
Name: this.Name,
|
Name: this.Name,
|
||||||
Nos: this.Nos,
|
Nos: this.Nos,
|
||||||
createdAt: this.createdAt,
|
createdAt: this.createdAt,
|
||||||
updatedAt: this.updatedAt
|
updatedAt: this.updatedAt,
|
||||||
}
|
};
|
||||||
|
|
||||||
return full ? {
|
return full
|
||||||
...view
|
? {
|
||||||
// add properties for a full view
|
...view,
|
||||||
} : 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 const schema = model.schema;
|
||||||
export default model
|
export default model;
|
||||||
|
|
|
@ -7,7 +7,7 @@ import { schema } from "./model";
|
||||||
export Doctor, { schema } from "./model";
|
export Doctor, { schema } from "./model";
|
||||||
|
|
||||||
const router = new Router();
|
const router = new Router();
|
||||||
const { ID, Name, Dapartment } = schema.tree;
|
const { docID, Name, Dapartment } = schema.tree;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @api {post} /Doctors Create doctor
|
* @api {post} /Doctors Create doctor
|
||||||
|
@ -69,7 +69,7 @@ router.get("/:id", show);
|
||||||
router.put(
|
router.put(
|
||||||
"/:id",
|
"/:id",
|
||||||
token({ required: true, roles: ["admin"] }),
|
token({ required: true, roles: ["admin"] }),
|
||||||
body({ ID, Name, Dapartment }),
|
body({ docID, Name, Dapartment }),
|
||||||
update
|
update
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -1,43 +1,50 @@
|
||||||
import mongoose, { Schema } from 'mongoose'
|
import mongoose, { Schema } from "mongoose";
|
||||||
|
|
||||||
const doctorSchema = new Schema({
|
const doctorSchema = new Schema(
|
||||||
ID: {
|
{
|
||||||
type: String
|
docID: {
|
||||||
|
type: String,
|
||||||
|
},
|
||||||
|
Name: {
|
||||||
|
type: String,
|
||||||
|
},
|
||||||
|
Dapartment: {
|
||||||
|
type: String,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
Name: {
|
{
|
||||||
type: String
|
timestamps: true,
|
||||||
},
|
toJSON: {
|
||||||
Dapartment: {
|
virtuals: true,
|
||||||
type: String
|
transform: (obj, ret) => {
|
||||||
|
delete ret._id;
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}, {
|
);
|
||||||
timestamps: true,
|
|
||||||
toJSON: {
|
|
||||||
virtuals: true,
|
|
||||||
transform: (obj, ret) => { delete ret._id }
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
doctorSchema.methods = {
|
doctorSchema.methods = {
|
||||||
view (full) {
|
view(full) {
|
||||||
const view = {
|
const view = {
|
||||||
// simple view
|
// simple view
|
||||||
id: this.id,
|
id: this.id,
|
||||||
ID: this.ID,
|
docID: this.docID,
|
||||||
Name: this.Name,
|
Name: this.Name,
|
||||||
Dapartment: this.Dapartment,
|
Dapartment: this.Dapartment,
|
||||||
createdAt: this.createdAt,
|
createdAt: this.createdAt,
|
||||||
updatedAt: this.updatedAt
|
updatedAt: this.updatedAt,
|
||||||
}
|
};
|
||||||
|
|
||||||
return full ? {
|
return full
|
||||||
...view
|
? {
|
||||||
// add properties for a full view
|
...view,
|
||||||
} : 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 const schema = model.schema;
|
||||||
export default model
|
export default model;
|
||||||
|
|
Loading…
Reference in New Issue