text: const { Schema, model } = require('mongoose');
  const dateFormat = require('../utils/dateFormat');
  
  const ReactionSchema = new Schema(
    {
      reactionId: {
        type: Schema.Types.ObjectId,
        default: () => Types.ObjectId(),
      },
      reactionBody: {
        type: String,
        required: 'Text is Required',
        maxlength: 280,
      },
      username: {
        type: String,
        required: true,
      },
      createdAt: {
        type: Date,
        default: Date.now,
        get: (createdAtVal) => dateFormat(createdAtVal),
      },
    },
    {
      toJSON: {
        getters: true,
      },
      id: false,
    }
  );
  
  const ThoughtSchema = new Schema(
    {
      thoughtText: {
        type: String,
        required: 'Please enter your thoughts',
        minlength: 1,
        maxlength: 280,
      },
      createdAt: {
        type: Date,
        default: Date.now,
        get: (createdAtVal) => dateFormat(createdAtVal),
      },
      username: {
        type: String,
        required: true,
      },
      reactions: [ReactionSchema],
    },
    {
      toJSON: {
        virtuals: true,
        getters: true,
      },
      id: false,
    }
  );
  
  // get total count of reactions on retrieval
  ThoughtSchema.virtual('reactionCount').get(function () {
    return this.reactions.length;
  });
  
  // create the Thought model using the ThoughtSchema
  const Thought = model('Thought', ThoughtSchema);
  
  // export the Thought model
  module.exports = Thought;
  