Skip to content

Commit

Permalink
Merge pull request #24 from chikatlarakesh/patch-2
Browse files Browse the repository at this point in the history
Code Enhancements and Bug Fixes for QuizQuest Backend Models
  • Loading branch information
BhattAnsh authored Oct 4, 2024
2 parents eedbdb7 + 9c2103f commit f29fb08
Showing 1 changed file with 22 additions and 17 deletions.
39 changes: 22 additions & 17 deletions QuizQuestBackend/src/models/quiz.model.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import mongoose, { mongo } from "mongoose";
import mongoose from "mongoose";

const codeSchmea = new mongoose.Schema({
code:{
type:String,
required:true,
}
})
// Code Schema
const codeSchema = new mongoose.Schema({
code: {
type: String,
required: true,
},
});

// Question Schema
const questionSchema = new mongoose.Schema({
question: {
type: String,
Expand All @@ -22,7 +25,8 @@ const questionSchema = new mongoose.Schema({
},
});

const quizSchema = mongoose.Schema({
// Quiz Schema
const quizSchema = new mongoose.Schema({
name: {
type: String,
required: true,
Expand All @@ -32,22 +36,23 @@ const quizSchema = mongoose.Schema({
required: true,
},
liveUntil: {
type: String,
type: Date, // Changed to Date type for proper date handling
required: true,
},
createdOn: {
type: Date,
default: Date.now,
},
questions: [{ type: mongoose.Schema.Types.ObjectId, ref: "Question", default:[] }],
createdBy: [{ type: mongoose.Schema.Types.ObjectId, ref: "User", required:true}],
quizCode:[{
type:mongoose.Schema.Types.ObjectId,
ref:"Code",
required:true
}]
questions: [{ type: mongoose.Schema.Types.ObjectId, ref: "Question", default: [] }],
createdBy: { type: mongoose.Schema.Types.ObjectId, ref: "User", required: true }, // Changed to single reference
quizCode: [{
type: mongoose.Schema.Types.ObjectId,
ref: "Code",
required: true,
}],
});

// Export Models
export const Quiz = mongoose.model("Quiz", quizSchema);
export const Question = mongoose.model("Question", questionSchema);
export const Code = mongoose.model("Code", codeSchmea);
export const Code = mongoose.model("Code", codeSchema);

0 comments on commit f29fb08

Please sign in to comment.