I am working on an examination system. There are four collections in the system:
teacher collection:
var mongoose = require("mongoose");
var Schema = mongoose.Schema;
var QuestionSchema = new Schema({
name: String, //
_teacher: { type: Schema.Types.ObjectId, ref: "Teacher" }, //
_papers: [{ type: Schema.Types.ObjectId, ref: "Paper" }], //
content: String, //
selection: [String], //
type: {type:String,enum:[ //
"single", //
"multi", //
"Q&A", //
"judgement" //
]},
score: Number, //
answer: String //
});
module.exports = mongoose.model("Question", QuestionSchema);
in the system, teachers can add test papers, so I don"t know how to save the data sent from the front desk. There are not only information about the examination papers, but also a lot of questions in the data. All the questions belong to the test paper, and the changed paper belongs to the teacher who currently logs in to the system (that is, the teacher who created the test paper).
how can test papers, teachers, and questions be related? ref stores _ id, but these new data are saved before _ id.
this question has been bothering me for many days. I hope some god can answer it. Thank you very much!
Thank you first ~