Created
April 2, 2019 04:03
-
-
Save jgcmarins/c2c92cbd071d95b49cc7296f494fcbf7 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 = new mongoose.Schema( | |
{ | |
name: { | |
type: String, | |
trim: true, | |
index: true, | |
}, | |
email: { | |
type: String, | |
index: true, | |
lowercase: true, | |
trim: true, | |
}, | |
manager: { | |
type: ObjectId, | |
ref: 'User', | |
description: 'Manager of this user', | |
required: false, | |
index: true, | |
} | |
}, | |
{ | |
timestamps: { | |
createdAt: 'createdAt', | |
updatedAt: 'updatedAt', | |
}, | |
collection: 'User', | |
}, | |
); | |
const UserModel = mongoose.model('User', Schema); | |
export default UserModel; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment