Modifying the user model

We don't need much information about a user, so we can reduce the User schema to only the strictly necessary information. Also, we can add a profile field, which can hold any extra info about the user, such as social media profile info or other accounts data.

Let's modify the User schema from app/models/user.js with the following:

const UserSchema = new Schema({
  email:  {
    type: String,
    required: true,
    unique: true
  },
  name: {
    type: String
  },
  password: {
    type: String,
    required: true,
    select: false
  },
  passwordSalt: {
    type: String,
    required: true,
    select: false
  },
  profile: {
    type: Mixed
  },
  createdAt: {
    type: Date,
    default: Date.now
  }
});

Get MEAN Blueprints now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.