Advertisement
Guest User

Untitled

a guest
Nov 20th, 2017
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //How I'm defining a user model in my application
  2. module.exports = mongoose.model( "User",
  3.     {
  4.         username : {
  5.             type : String,
  6.             default: "",
  7.             unique: true
  8.         },
  9.         password : {
  10.             type : String,
  11.             default: ""
  12.         },
  13.         firstName: {
  14.             type : String,
  15.             default: ""
  16.         },
  17.         lastName : {
  18.             type : String,
  19.             default: ""
  20.         },
  21.         email    : {
  22.             type : String,
  23.             default: "",
  24.             validate: isValidEmail,
  25.             unique: true
  26.         }
  27.     }
  28. );
  29.  
  30. //How Mongoose docs show defining a model:
  31. var userSchema = new Schema( {
  32.     username : {
  33.         type : String,
  34.         default: "",
  35.         unique: true
  36.     },
  37.     password : {
  38.         type : String,
  39.         default: ""
  40.     },
  41.     firstName: {
  42.         type : String,
  43.         default: ""
  44.     },
  45.     lastName : {
  46.         type : String,
  47.         default: ""
  48.     },
  49.     email    : {
  50.         type : String,
  51.         default: "",
  52.         validate: isValidEmail,
  53.         unique: true
  54.     }
  55. } );
  56. var userModel = mongoose.model( "User", useSchema );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement