Skip to content

Instantly share code, notes, and snippets.

@jgcmarins
Created April 2, 2019 04:03
Show Gist options
  • Save jgcmarins/c2c92cbd071d95b49cc7296f494fcbf7 to your computer and use it in GitHub Desktop.
Save jgcmarins/c2c92cbd071d95b49cc7296f494fcbf7 to your computer and use it in GitHub Desktop.
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