feat(entities): Added created/updated at to all entities

This commit is contained in:
2025-05-06 19:33:30 +02:00
parent a4480589a0
commit 728f8a14e9
12 changed files with 279 additions and 17 deletions

View File

@@ -1,5 +1,5 @@
import { IsInt, IsOptional, IsString } from "class-validator";
import { Column, Entity, PrimaryGeneratedColumn } from "typeorm";
import { IsInt, IsOptional, IsPositive, IsString } from "class-validator";
import { BeforeInsert, BeforeUpdate, Column, Entity, PrimaryGeneratedColumn } from "typeorm";
import { ResponseStatsClient } from '../responses/ResponseStatsClient';
/**
* Defines the StatsClient entity.
@@ -47,6 +47,27 @@ export class StatsClient {
@IsOptional()
cleartextkey?: string;
@Column({ type: 'bigint', nullable: true, readonly: true })
@IsInt()
@IsPositive()
created_at: number;
@Column({ type: 'bigint', nullable: true })
@IsInt()
@IsPositive()
updated_at: number;
@BeforeInsert()
public setCreatedAt() {
this.created_at = Math.floor(Date.now() / 1000);
this.updated_at = Math.floor(Date.now() / 1000);
}
@BeforeUpdate()
public setUpdatedAt() {
this.updated_at = Math.floor(Date.now() / 1000);
}
/**
* Turns this entity into it's response class.
*/