Skip to content

Commit

Permalink
database schema added
Browse files Browse the repository at this point in the history
  • Loading branch information
Luxshan2000 committed Oct 12, 2023
1 parent 983783c commit e53a629
Show file tree
Hide file tree
Showing 3 changed files with 187 additions and 2 deletions.
39 changes: 38 additions & 1 deletion backend/config/database.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require('dotenv').config();
const mongoose = require("mongoose")
const mongoose = require("mongoose");
const Topic = require('../src/models/topic');


const connectMongoDb = ()=>{
Expand All @@ -10,6 +11,42 @@ const connectMongoDb = ()=>{
console.log('====================================');
console.log("mongoDB is sucessfully connected!");
console.log('====================================');

/*Debugging Purpose*/
// const sample = async ()=>{
// const title = "Overview"
// const no = 1
// const videoUrl = "videourl"
// const script = '<h1 >This is an script</h1>'
// const questions = [
// {
// ques: "Question 1",
// answer: "Answer 1",
// posFeedback: "Correct!",
// negativeFeedback: "Sorry, wrong answer.",
// options: ["Option A", "Option B", "Option C"],
// correctOption: "Option B"
// },
// {
// ques: "Question 2",
// answer: "Answer 2",
// posFeedback: "Good job!",
// negativeFeedback: "Try again.",
// options: ["Option X", "Option Y", "Option Z"],
// correctOption:"Option X"
// }
// // Add more questions as needed
// ]


// const topic = new Topic({title,no,videoUrl, script, questions })

// await topic.save()
// }

// sample()


}).catch((error)=>{
console.log('====================================');
console.log("mongoDB configration error\n",error);
Expand Down
60 changes: 60 additions & 0 deletions backend/src/models/topic.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
const mongoose = require("mongoose")

const Topic= mongoose.model("topics",{
title:{
type:String,
required:true,
unique:true
},
no:{
type:String,
required:true,
unique: true
},
videoUrl: {
type:String
},
popQuiz:[
{
quizId: {
type: Number,
required: true
},
popTime:{
type: Number, //in seconds
required: true
}
}
],
script:{
type: String,
},
questions: [
{
ques: {
type: String,
required: true,
trim: true
},
answer: {
type: String,
required: true,
trim: true
},
posFeedback: {
type: String,
trim: true
},
negativeFeedback: {
type: String,
trim: true
},
options: [{
type: String,
trim: true
}],
}
]
})

module.exports = Topic
90 changes: 89 additions & 1 deletion backend/src/models/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,98 @@ const User= mongoose.model("users",{
type:Boolean,
default:false
},
preLanguage:{
type:Strig,
default:"English",
required: true,
enum :["Sinhala", "Tamil", "English"]
},
otp: {
type : String,
default:null
}
},
payments:[
{
amount:{
type: Number,
required: true,
default: 400
},
subcriDate:{
type: Date,
required: true,
default: Date.now
}
}
],
refundRequests:[
{
reqDate:{
type: Date,
trim : true,
required : true
},
resDate:{
type: Date,
trim : true
},
Status: {
type: String,
trim : true,
default: "Open",
enum :["Opened", "Accepted", "Rejected"]
}
}
],
isAdmin:{
type: Boolean,
required: true
},
query:[
{
req:{
type: String,
required: true,
trim: true
},
res:{
type: String,
trim: true
},
reqDate:{
type: Date,
required: true
},
resDate:{
type: Date,
required: true
},
status:{
type: String,
default: "Open",
required: true,
enum:["Open","Closed"]
}
}
],
completed:[
{
topicId:{
type: Number,
required: true
},
isVideoFinished:{
type: Boolean,
required: true,
default: false
},
isQuizFinished:{
type: Boolean,
required: true,
default: false
}
}
]
})

module.exports = User

0 comments on commit e53a629

Please sign in to comment.