Last active
February 2, 2019 16:26
-
-
Save darklam/6d6012285392b29385c6445ee5b628a7 to your computer and use it in GitHub Desktop.
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
export interface UserInterface extends mongoose.Document { | |
username: string; | |
passwordHash: string; | |
accessRights: string; | |
createdAt: Date; | |
updatedAt: Date; | |
} |
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
const userSchema = new Schema({ | |
username: { | |
type: String, | |
required: true, | |
trim: true | |
}, | |
passwordHash: { | |
type: String, | |
required: true | |
}, | |
accessRights: { | |
type: String, | |
enum: ['user', 'admin'], | |
default: 'user' | |
} | |
}, | |
{ | |
timestamps: true | |
}); | |
export const User: mongoose.Model<UserInterface> = mongoose.model('User', userSchema, 'Users'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment