text: const { Schema, model } = require("mongoose");
  const reactionSchema = require("./Reaction");
  const dateFormat = require("./../utils/dateFormat");
  
  // Schema to create Student model
  const thoughtSchema = new Schema(
    {
      thoughtText: {
        type: String,
        required: true,
        max_length: 280,
        minlength: 1,
      },
      createdAt: {
        type: Date,
        immutable: true,
        default: Date.now,
        get: dateFormat,
      },
      username: {
        type: String,
        required: true,
      },
      reactions: [reactionSchema],
    },
    {
      toJSON: {
        getters: true,
      },
    }
  );
  
  thoughtSchema.virtual("reactionCount").get(function () {
    return this.reactions.length;
  });
  
  const Thought = model("Thought", thoughtSchema);
  
  module.exports = { Thought, thoughtSchema };
  