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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.