text: // // necessary dependencies
  const { Schema, model } = require('mongoose');
  
  // user schema model
  const UserSchema = new Schema(
    {
      username: {
        type: String,
        unique: true,
        required: true,
        trim: true
      },
      email: {
        type: String,
        required: true,
        match: /.+\@.+\..+/,
        unique: true
      },
      thoughts: [
        {
          type: Schema.Types.ObjectId,
          ref: 'Thought'
        }
      ],
      friends: [
        {
          type: Schema.Types.ObjectId,
          ref: 'User'
        }
      ]
    },
    {
      toJSON: {
        virtuals: true,
        getters: true
      },
      // prevents virtuals from creating duplicate of _id as `id`
      id: false
    }
  );
  
  // mongoose virtual that gets total count of user friends
  UserSchema.virtual('friendCount').get(function() {
    return this.friends.length;
  });
  
  const User = model('User', UserSchema);
  
  module.exports = User;