Skip to content

Instantly share code, notes, and snippets.

@daniloab
Last active June 12, 2019 18:23
Show Gist options
  • Save daniloab/10011b510f06fffedfd57ae2215ce0b1 to your computer and use it in GitHub Desktop.
Save daniloab/10011b510f06fffedfd57ae2215ce0b1 to your computer and use it in GitHub Desktop.
Simple example user model
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