import { type ObjectId, Schema, model, Model } from 'mongoose';
export interface FormResponseI extends Document{
form: ObjectId;
response: {
elementType: string;
question: string;
answer: any;
}[];
}
interface FormResponseModelI extends Model<FormResponseI> {}
const formResponseSchema = new Schema<FormResponseI>(
{
form: {
type: Schema.ObjectId,
ref: 'Form',
required: true,
},
response: [
{
elementType: String,
question: String,
answer: Schema.Types.Mixed,
},
],
},
{
timestamps: true,
}
);
const formResponseModel = model<FormResponseI,FormResponseModelI>('FormResponse', formResponseSchema);
export default formResponseModel;