first commit
This commit is contained in:
47
api/src/entities/User.ts
Normal file
47
api/src/entities/User.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
import { Column, CreateDateColumn, Entity, OneToMany, PrimaryGeneratedColumn } from 'typeorm';
|
||||
import { Category } from './Category.js';
|
||||
import { Expense } from './Expense.js';
|
||||
|
||||
export type UserRole = 'ADMIN' | 'USER';
|
||||
|
||||
@Entity('users')
|
||||
export class User {
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
id!: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 120 })
|
||||
fullName!: string;
|
||||
|
||||
@Column({ type: 'varchar', unique: true, length: 160 })
|
||||
email!: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 255 })
|
||||
passwordHash!: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 20, default: 'USER' })
|
||||
role!: UserRole;
|
||||
|
||||
@Column({ type: 'boolean', default: true })
|
||||
isActive!: boolean;
|
||||
|
||||
@Column({ type: 'varchar', length: 8, default: 'PLN' })
|
||||
defaultCurrency!: string;
|
||||
|
||||
@Column({ type: 'simple-json', nullable: true })
|
||||
reportPreferences!: {
|
||||
enabled?: boolean;
|
||||
frequency?: 'monthly' | 'yearly' | 'threshold';
|
||||
thresholdAmount?: number;
|
||||
sendToEmail?: string | null;
|
||||
categoryIds?: string[];
|
||||
} | null;
|
||||
|
||||
@CreateDateColumn({ type: 'datetime' })
|
||||
createdAt!: Date;
|
||||
|
||||
@OneToMany(() => Category, (category) => category.user)
|
||||
categories!: Category[];
|
||||
|
||||
@OneToMany(() => Expense, (expense) => expense.user)
|
||||
expenses!: Expense[];
|
||||
}
|
||||
Reference in New Issue
Block a user