-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Modify model|add teacher model crud|fix some error
- Loading branch information
1 parent
228bd97
commit b88ffeb
Showing
9 changed files
with
68 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import Teacher from '../model/teacherModel.js'; | ||
|
||
// import AppError from '../utils/appError.js'; | ||
// import catchAsync from '../utils/catchAsync.js'; | ||
// import factory from './handlerFactory.js'; | ||
import * as factory from './handlerFactory.js'; | ||
// const factory = require('./handlerFactory'); | ||
|
||
export const getAllTeacherPost = factory.getAll(Teacher); | ||
|
||
export const createTeacherPost = factory.createOne(Teacher); | ||
export const getTeacherPost = factory.getOne(Teacher); | ||
export const updateTeacherPost = factory.updateOne(Teacher); | ||
export const deleteTeacherPost = factory.deleteOne(Teacher); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,16 @@ | ||
import mongoose from 'mongoose'; | ||
|
||
const courseSchema = new mongoose.Schema({ | ||
course_name: { | ||
courseName: { | ||
type: String, | ||
required: [true, 'A course must have a course name'], | ||
}, | ||
course_code: { | ||
courseCode: { | ||
type: String, | ||
required: [true, 'A course must have a course name'], | ||
}, | ||
credit: Number | ||
|
||
}); | ||
|
||
export default mongoose.model('Course', courseSchema); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import mongoose from 'mongoose'; | ||
|
||
const teacherSchema = new mongoose.Schema({ | ||
teacherInitial: { | ||
type: String, | ||
required: [true, "A course allocation has a teacher Initial"] | ||
}, | ||
takenCredit: { | ||
type: Number, | ||
required: [true, "A course allocation has a taken Credit"] | ||
}, | ||
courseId: [{ | ||
type:mongoose.Schema.ObjectId, | ||
ref:'Course' | ||
}] | ||
}) | ||
|
||
export default mongoose.model('Teacher', teacherSchema); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import express from 'express'; | ||
import * as teacherController from '../contollers/teacherController.js'; | ||
const router = express.Router(); | ||
|
||
|
||
router.get('/', teacherController.getAllTeacherPost); | ||
router.post('/create-teacher', teacherController.createTeacherPost); | ||
router.get('/teacher-details/:id', teacherController.getTeacherPost); | ||
router.patch('/update-teacher', teacherController.updateTeacherPost); | ||
router.delete('/delete-teacher', teacherController.deleteTeacherPost); | ||
|
||
|
||
|
||
export default router; |