lecture.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. const mongoose = require("mongoose");
  2. const AnswerSchema = new mongoose.Schema({
  3. name: String,
  4. content: {
  5. type: String,
  6. required: true
  7. },
  8. createdAt: {
  9. type: Date,
  10. default: new Date()
  11. }
  12. });
  13. const QuestionSchema = new mongoose.Schema({
  14. name: String,
  15. title: {
  16. type: String,
  17. required: true
  18. },
  19. content: {
  20. type: String,
  21. required: true,
  22. minlength: 15
  23. },
  24. answers: [AnswerSchema],
  25. createdAt: {
  26. type: Date,
  27. default: new Date()
  28. }
  29. });
  30. const LectureSchema = new mongoose.Schema({
  31. course: {
  32. type: mongoose.Schema.Types.ObjectId,
  33. ref: "Course",
  34. required: true
  35. },
  36. title: {
  37. type: String,
  38. required: true
  39. },
  40. video: {
  41. type: String,
  42. required: true
  43. },
  44. description: {
  45. type: String,
  46. required: true,
  47. },
  48. furtherReading: [{
  49. text: String,
  50. link: String
  51. }],
  52. documents: [{
  53. name: String,
  54. link: String
  55. }],
  56. exercises: [String],
  57. createdDate: {
  58. type: Date,
  59. default: new Date(),
  60. required: true
  61. },
  62. updatedDate: {
  63. type: Date,
  64. required: false
  65. },
  66. questions: [QuestionSchema]
  67. });
  68. module.exports = mongoose.model("Lecture", LectureSchema);