Made route field in courses

This commit is contained in:
hardcodder 2021-05-05 18:26:43 +05:30
parent cf9549cb6c
commit d279de1c68
4 changed files with 32 additions and 2 deletions

View File

@ -8,6 +8,7 @@ module.exports.postAddCourse = async (req , res , next) => {
let name = req.body.name ; let name = req.body.name ;
let mentor = req.body.mentor ; let mentor = req.body.mentor ;
let totalLectures = req.body.totalLectures ; let totalLectures = req.body.totalLectures ;
let route = req.body.route
if(name) if(name)
{ {
name = name.trim() ; name = name.trim() ;
@ -16,6 +17,10 @@ module.exports.postAddCourse = async (req , res , next) => {
{ {
mentor = mentor.trim() ; mentor = mentor.trim() ;
} }
if(route)
{
route = route.trim() ;
}
if(totalLectures) if(totalLectures)
{ {
totalLectures = Number(totalLectures) ; totalLectures = Number(totalLectures) ;
@ -24,7 +29,8 @@ module.exports.postAddCourse = async (req , res , next) => {
let course = new Course({ let course = new Course({
name : name , name : name ,
mentor : mentor , mentor : mentor ,
totalLectures : totalLectures totalLectures : totalLectures ,
route : route
}) ; ; }) ; ;
course = await course.save() ; course = await course.save() ;
@ -147,3 +153,21 @@ module.exports.getTierCourse = async (req , res , next) => {
}) })
} }
} }
module.exports.getFromRoute = async (req , res , next) => {
try{
const route = req.query.route ;
const course = await Course.findOne({route :route}).populate("types.tier1").populate("types.tier2").populate("types.tier3") ;
console.log(course);
res.json({
course : course
})
}
catch(err)
{
res.json({
error : "error"
})
}
}

View File

@ -103,7 +103,7 @@ module.exports.postRazorpay = async (req , res , next) => {
//this route will be called after clicking the payment //this route will be called after clicking the payment
//here this is the id of courseType //here this is the id of courseType
const courseId = req.body.courseId || "6074201a4f355c3e4830dfe0" ; const courseId = req.body.courseId ;
const userId = req.user._id ; const userId = req.user._id ;
let user = await User.findById(userId) ; let user = await User.findById(userId) ;
let student =await Student.findById(user.student) ; let student =await Student.findById(user.student) ;

View File

@ -15,6 +15,10 @@ const courseSchema = new Schema({
type : Number , type : Number ,
required : true required : true
} , } ,
route: {
type : String ,
required : true
} ,
meetings : [ meetings : [
{ {
startTime : { startTime : {

View File

@ -19,4 +19,6 @@ router.post('/getTierCourse' , courseController.getTierCourse) ;
//It is a post request //It is a post request
router.post('/getMeetSchedule' ,isAuth , courseController.getMeetSchedule) ; router.post('/getMeetSchedule' ,isAuth , courseController.getMeetSchedule) ;
router.get('/getFromRoute' , courseController.getFromRoute) ;
module.exports = router ; module.exports = router ;