38 lines
831 B
TypeScript
38 lines
831 B
TypeScript
import { Entity, PrimaryGeneratedColumn, Column, OneToMany } from 'typeorm'
|
|
import { Link } from './Link'
|
|
|
|
@Entity("users")
|
|
export class User {
|
|
|
|
// Unique user id.
|
|
@PrimaryGeneratedColumn()
|
|
id: number | undefined; // Is this a good idea?
|
|
|
|
// User name, must be unique.
|
|
@Column({ unique: true })
|
|
name: string;
|
|
|
|
// Salted password hash.
|
|
@Column()
|
|
passwordHash: string;
|
|
|
|
// Used to tell, whether password hash should
|
|
// be recalculated (salted) on next login.
|
|
@Column()
|
|
dirtyPasswordHashBit: boolean;
|
|
|
|
// User role:
|
|
// - 0 - means unprivileged user,
|
|
// - 1 - means administrative user.
|
|
@Column()
|
|
role: number;
|
|
|
|
// Account creation date as a Unix timestamp.
|
|
@Column('bigint')
|
|
createdAt: number;
|
|
|
|
// List of shortened URLs which belong to the user.
|
|
@OneToMany(() => Link, (link) => link.author)
|
|
links: Link[];
|
|
}
|