File tree Expand file tree Collapse file tree 1 file changed +53
-0
lines changed
Expand file tree Collapse file tree 1 file changed +53
-0
lines changed Original file line number Diff line number Diff line change 1+ import { model , Schema , Document } from 'mongoose'
2+
3+ export interface IUser extends Document {
4+ displayName : string ;
5+ username : string ;
6+ email : string ;
7+ password : string ;
8+ avatar : string ;
9+ role : string ;
10+ status : boolean ;
11+ }
12+
13+ const UserSchema = new Schema ( {
14+ displayName : {
15+ type : String ,
16+ required : true
17+ } ,
18+ username : {
19+ type : String ,
20+ minlength : 4 ,
21+ required : true
22+ } ,
23+ email : {
24+ type : String ,
25+ unique : true ,
26+ trim : true ,
27+ lowercase : true ,
28+ required : true
29+ } ,
30+ password : {
31+ type : String ,
32+ minlength : 6 ,
33+ required : true
34+ } ,
35+ avatar : {
36+ type : String ,
37+ maxlength : 512 ,
38+ required : false
39+ } ,
40+ role : {
41+ type : String ,
42+ enum : [ "SUPERADMIN" , "ADMIN" , "USER" ] ,
43+ default : "USER"
44+ } ,
45+ status : {
46+ type : Boolean ,
47+ default : true
48+ }
49+ } , {
50+ timestamps : true
51+ } )
52+
53+ export default model < IUser > ( 'User' , UserSchema )
You can’t perform that action at this time.
0 commit comments