40 lines
1.1 KiB
JavaScript
40 lines
1.1 KiB
JavaScript
const mongoose = require('mongoose');
|
|
|
|
const formSubmissionSchema = new mongoose.Schema(
|
|
{
|
|
form: {
|
|
type: mongoose.Schema.Types.ObjectId,
|
|
ref: 'Form',
|
|
required: true,
|
|
},
|
|
tenantOrganization: {
|
|
type: mongoose.Schema.Types.ObjectId,
|
|
ref: 'Organization',
|
|
required: true,
|
|
},
|
|
participant: { type: mongoose.Schema.Types.ObjectId, ref: 'Participant' },
|
|
user: { type: mongoose.Schema.Types.ObjectId, ref: 'User' },
|
|
event: {
|
|
type: mongoose.Schema.Types.ObjectId,
|
|
ref: 'Event',
|
|
required: false,
|
|
},
|
|
data: { type: Map, of: mongoose.Schema.Types.Mixed },
|
|
status: {
|
|
type: String,
|
|
enum: ['submitted', 'reviewed', 'approved', 'rejected'],
|
|
default: 'submitted',
|
|
},
|
|
submittedAt: { type: Date, default: Date.now },
|
|
reviewedAt: Date,
|
|
reviewedBy: { type: mongoose.Schema.Types.ObjectId, ref: 'User' },
|
|
notes: String,
|
|
},
|
|
{ timestamps: true }
|
|
);
|
|
|
|
formSubmissionSchema.index({ form: 1 });
|
|
formSubmissionSchema.index({ participant: 1 });
|
|
formSubmissionSchema.index({ tenantOrganization: 1 });
|
|
module.exports = mongoose.model('FormSubmission', formSubmissionSchema);
|