Closed b-d-johnson closed 7 years ago
Some ideas:
const userSchema = Schema({
username: { type: String, required: true, unique: true },
email: { type: String, required: true, unique: true },
password: { type: String, required: true },
findHash: { type: String, unique: true }
});
const questionSchema = Schema({
question: { type: String, required: true },
created: { type: Date, required: true, default: Date.now },
answers: [AnswerSchema],
userID: { type: mongoose.Schema.Types.ObjectId, required: true }
});
const answerSchema = Schema({
answer: { type: String, required: true },
created: { type: Date, default: Date.now },
updated: { type: Date, default: Date.now },
votes: {type: Number, default:0},
userID: { type: Schema.Types.ObjectId, required: true }
});
answerSchema could have methods to update
and vote
.