Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //How I'm defining a user model in my application
- module.exports = mongoose.model( "User",
- {
- username : {
- type : String,
- default: "",
- unique: true
- },
- password : {
- type : String,
- default: ""
- },
- firstName: {
- type : String,
- default: ""
- },
- lastName : {
- type : String,
- default: ""
- },
- email : {
- type : String,
- default: "",
- validate: isValidEmail,
- unique: true
- }
- }
- );
- //How Mongoose docs show defining a model:
- var userSchema = new Schema( {
- username : {
- type : String,
- default: "",
- unique: true
- },
- password : {
- type : String,
- default: ""
- },
- firstName: {
- type : String,
- default: ""
- },
- lastName : {
- type : String,
- default: ""
- },
- email : {
- type : String,
- default: "",
- validate: isValidEmail,
- unique: true
- }
- } );
- var userModel = mongoose.model( "User", useSchema );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement