backend/src/models/entities/UserAction.ts

51 lines
854 B
TypeScript

import {
IsInt,
IsNotEmpty,
IsOptional,
IsString
} from "class-validator";
import { Column, Entity, ManyToOne, PrimaryGeneratedColumn } from "typeorm";
import { User } from './User';
/**
* Defines the UserAction interface.
*/
@Entity()
export class UserAction {
/**
* Autogenerated unique id (primary key).
*/
@PrimaryGeneratedColumn()
@IsInt()
id: number;
/**
* user
*/
@ManyToOne(() => User, user => user.actions)
user: User
/**
* The actions's target (e.g. Track#2)
*/
@Column()
@IsNotEmpty()
@IsString()
target: string;
/**
* The actions's action (e.g. UPDATE)
*/
@Column()
@IsNotEmpty()
@IsString()
action: string;
/**
* The description of change (before-> after; e.g. distance:15->17)
*/
@Column({ nullable: true })
@IsOptional()
@IsString()
changed: string;
}