text: //this is the model for the thought
  
  const { Schema, model } = require('mongoose');
  const { reactionSchema } = require('./Reaction');
  const dateFormat = require('../utils/dateFormat');
  
  // Thought schema
  const thoughtSchema = new Schema(
    {
      thoughtText: {
        type: String,
        required: 'You need to leave a thought!',
        minlength: 1,
        maxlength: 280
      },
  
      createdAt: {
        type: Date,
        default: Date.now,
        get: timestamp => dateFormat(timestamp)
      },
  
      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;
  