text: const { Schema, model } = require('mongoose');
  const moment = require('moment');
  
  
  const UserSchema = new Schema({
    username: {
      type: String,
      required: true,
      unique: true,
      trim: true
    },
    email: {
      type: String,
      required: true,
      unique: true,
      trim: true,
      match: [/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/, 'Please enter a valid email address']
    },
    thoughts: [
        {
            type: Schema.Types.ObjectId,
            ref: 'Thought'
        }
      ],
    friends: [
        {
            type: Schema.Types.ObjectId,
            ref: 'User'
        }
    ]
    },
    { 
    toJSON: {
      virtuals: true,
      getters: true
    },
    id: false
  }
  );
  
  // create user model using schema
  const User = model('User', UserSchema);
  
  // get comments and replies on retrieval 
  UserSchema.virtual('friendCount').get(function() {
    return this.friends.length;
  });
  
  
    // export the user model
  module.exports = User;