64 lines
1.0 KiB
TypeScript
64 lines
1.0 KiB
TypeScript
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
|
|
import { Document } from 'mongoose';
|
|
import {ApiProperty} from '@nestjs/swagger';
|
|
|
|
interface Token {
|
|
token: string;
|
|
expired_at: string;
|
|
}
|
|
|
|
export class UserRequest {
|
|
@ApiProperty()
|
|
login: string;
|
|
|
|
@ApiProperty()
|
|
avatar: string;
|
|
|
|
@ApiProperty()
|
|
is_admin: string;
|
|
}
|
|
|
|
@Schema()
|
|
export class User extends Document {
|
|
@Prop({
|
|
required: true,
|
|
unique: true,
|
|
type: String,
|
|
})
|
|
login: string;
|
|
|
|
@Prop({
|
|
required: true,
|
|
type: String,
|
|
})
|
|
password: string;
|
|
|
|
@Prop({
|
|
type: String,
|
|
})
|
|
avatar: string;
|
|
|
|
@Prop({
|
|
type: Boolean,
|
|
})
|
|
is_admin: boolean;
|
|
|
|
@Prop({
|
|
type: {
|
|
token: String,
|
|
expired_at: String,
|
|
}
|
|
})
|
|
access_token: Token;
|
|
|
|
@Prop({
|
|
type: {
|
|
token: String,
|
|
expired_at: String,
|
|
}
|
|
})
|
|
refresh_token: Token;
|
|
}
|
|
|
|
export const UserSchema = SchemaFactory.createForClass(User);
|