Last active
June 12, 2019 18:23
-
-
Save daniloab/10011b510f06fffedfd57ae2215ce0b1 to your computer and use it in GitHub Desktop.
Simple example user model
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import mongoose from 'mongoose'; | |
const { ObjectId } = mongoose.Schema.Types; | |
const Schema = mongoose.Schema; | |
const UserSchema = new Schema({ | |
name: { | |
type: String, | |
required: 'name is required', | |
}, | |
username: { | |
type: String, | |
required: 'username is required', | |
}, | |
email: { | |
type: String, | |
required: 'email is required', | |
}, | |
password: { | |
type: String, | |
required: 'password is required', | |
}, | |
team: { | |
type: ObjectId, | |
ref: 'Team' | |
} | |
}, { timestamps: true }); | |
export default mongoose.model('User', UserSchema) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment