em-shop/users/src/users/user.model.ts
2024-11-20 09:53:03 +05:00

49 lines
1.2 KiB
TypeScript
Executable File

import { Column, DataType, Model, Table } from 'sequelize-typescript';
import { ApiProperty } from '@nestjs/swagger';
interface UserCreationAttrs {
firstName: string;
lastName: string;
birthday: string;
sex: number;
problems: boolean;
}
@Table({ tableName: 'user' })
export class User extends Model<User, UserCreationAttrs> {
@ApiProperty({ example: 1, description: 'Уникальный идентификатор' })
@Column({
type: DataType.INTEGER,
unique: true,
autoIncrement: true,
primaryKey: true,
})
id: number;
@ApiProperty({ example: 'Alice', description: 'First Name' })
@Column({ type: DataType.STRING, allowNull: false })
firstName: string;
@ApiProperty({ example: 'Smith', description: 'Last Name' })
@Column({ type: DataType.STRING, allowNull: false })
lastName: string;
@ApiProperty({
example: '2006-11-19 19:00:00.000 +00:00',
description: 'Birthday',
})
@Column(DataType.STRING)
birthday: string;
@ApiProperty({ example: 1, description: 'Sex' })
@Column({
type: DataType.INTEGER,
defaultValue: 0,
})
sex: number;
@ApiProperty({ example: true, description: 'Problems' })
@Column({ type: DataType.BOOLEAN, defaultValue: false })
problems: boolean;
}