// models/formSubmissionModel.js
const mongoose = require("mongoose");

const formSubmissionSchema = new mongoose.Schema(
  {
    formId: {
      type: mongoose.Schema.Types.ObjectId,
      ref: "Form",
      required: true,
    },
    data: {
      type: Object, // store form fieldId => value pairs
      required: true,
    },
    submittedBy: {
      type: String,
      default: null, // optional user info
    },
  },
  { timestamps: true } // adds createdAt & updatedAt
);

module.exports = mongoose.model("FormSubmission", formSubmissionSchema);
