diff --git a/packages/api/src/models/study.ts b/packages/api/src/models/study.ts index f90fbd0c..caa31a68 100644 --- a/packages/api/src/models/study.ts +++ b/packages/api/src/models/study.ts @@ -9,6 +9,8 @@ import type { IStudy, IStudyVariant, ITaskInstance, + IOptionValue, + ICustomizedSession, } from "@seitz/shared"; const taskInstanceSchema = new Schema({ @@ -25,9 +27,11 @@ const sessionSchema = new Schema({ tasks: [taskInstanceSchema], }); +export const Session = model("Session", sessionSchema); + const variantSchema = new Schema({ name: { type: String, default: "" }, - sessions: [sessionSchema], + sessions: [{ type: Schema.Types.ObjectId, ref: "CustomizedSession" }], serverCode: { type: String }, }); @@ -77,3 +81,17 @@ variantSchema.pre("save", async function (next) { }); export const Study = model("Study", studySchema); + +// TODO: Tech Debt - is there a better typing for this? +const optionValueSchema = new Schema({ + option: Schema.Types.ObjectId, + value: Schema.Types.Mixed, +}); + +export const customizedSessionSchema = new Schema({ + battery: { type: Schema.Types.ObjectId, ref: "Session", required: true }, + name: { type: String, required: true }, + values: [optionValueSchema], +}); + +export const CustomizedSession = model("CustomizedSession", sessionSchema);