Skip to content

Instantly share code, notes, and snippets.

@avastamin
Created July 13, 2020 16:38
Show Gist options
  • Save avastamin/cbfb69715c7ba2d78bd3103d66afaa12 to your computer and use it in GitHub Desktop.
Save avastamin/cbfb69715c7ba2d78bd3103d66afaa12 to your computer and use it in GitHub Desktop.
const mongoose = require("mongoose");
const Schema = mongoose.Schema;
//https://groups.google.com/forum/#!topic/mongodb-user/AdlvRy1AC_I
//https://stackoverflow.com/questions/45293832/simple-questionnaire-app-design-in-mongodb
// https://stackoverflow.com/questions/19672260/mongodb-schema-for-dynamic-questions-and-answers
// https://talk.birmingham.io/t/questionnaire-database-schema-help/1464
//https://stackoverflow.com/questions/9127174/why-does-mongoose-have-both-schemas-and-models
const QuestionSchema = new Schema({
name: String,
type: String,
hints: String,
});
const ConditionsGroupSchema = new Schema({
name: String,
questions: [QuestionSchema],
});
const ConditionsSchema = new Schema({
/* userID: {
type: mongoose.Schema.Types.ObjectId,
ref: "User",
},*/
conditionGroup: [ConditionsGroupSchema],
});
const Conditions = mongoose.model("Conditions", ConditionsSchema);
module.exports = Conditions;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment