All files / Zapcard_API/models user.js

100% Statements 6/6
100% Branches 0/0
100% Functions 0/0
100% Lines 6/6
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45      1x   1x 1x           1x                                                   1x         1x  
/**
* Module Dependencies
*/
const mongoose = require('mongoose');
 
mongoose.Promise = global.Promise;
require('mongoose-type-email');
 
 
/**
* Define the Database structure for User (Schema)
*/
const UserSchema = new mongoose.Schema({
  username: {
    type: String,
    required: true,
    index: {
      unique: true,
    },
  },
  name: {
    type: String,
  },
  about: {
    type: String,
  },
  profilePicture: {
    type: String,
  },
  password: {
    type: String,
    required: true,
  },
  email: {
    type: mongoose.SchemaTypes.Email,
  },
});
 
UserSchema.plugin(require('mongoose-bcrypt'));
 
/**
* Make the Schema available in the app
*/
module.exports = mongoose.model('User', UserSchema);