Created the User model
This commit is contained in:
parent
363f373e97
commit
63478822ba
56
models/User.ts
Normal file
56
models/User.ts
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
import mongoose, {Schema} from 'mongoose';
|
||||||
|
|
||||||
|
export enum Rank {
|
||||||
|
USER = "user",
|
||||||
|
TEAM_MEMBER = "team",
|
||||||
|
ADMIN = "admin"
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IUser {
|
||||||
|
clientId: number
|
||||||
|
username: string
|
||||||
|
locale: string
|
||||||
|
rank: Rank
|
||||||
|
avatarId: string
|
||||||
|
accessToken: string
|
||||||
|
refreshToken: string
|
||||||
|
created: Date
|
||||||
|
}
|
||||||
|
|
||||||
|
const UserSchema = new Schema<IUser>({
|
||||||
|
clientId: {
|
||||||
|
type: Number,
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
username: {
|
||||||
|
type: String,
|
||||||
|
default: "User#0001"
|
||||||
|
},
|
||||||
|
locale: {
|
||||||
|
type: String,
|
||||||
|
default: "en"
|
||||||
|
},
|
||||||
|
rank: {
|
||||||
|
type: String,
|
||||||
|
enum: Rank,
|
||||||
|
default: Rank.USER
|
||||||
|
},
|
||||||
|
avatarId: {
|
||||||
|
type: String,
|
||||||
|
default: "590962a0d694945a779054cd078a7efd"
|
||||||
|
},
|
||||||
|
accessToken: {
|
||||||
|
type: String,
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
refreshToken: {
|
||||||
|
type: String,
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
created: {
|
||||||
|
type: Date,
|
||||||
|
default: Date.now
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
export const User = mongoose.model('users', UserSchema);
|
Loading…
x
Reference in New Issue
Block a user