Skip to content

Instantly share code, notes, and snippets.

@darklam
Last active February 2, 2019 16:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save darklam/6d6012285392b29385c6445ee5b628a7 to your computer and use it in GitHub Desktop.
Save darklam/6d6012285392b29385c6445ee5b628a7 to your computer and use it in GitHub Desktop.
export interface UserInterface extends mongoose.Document {
username: string;
passwordHash: string;
accessRights: string;
createdAt: Date;
updatedAt: Date;
}
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