Skip to content

armgit / TREK

Public Imported from GitHub
0

The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.

1.1 KB
Raw Blame
import { EntityRepositoryType, type Opt, type Ref, defineEntity, p } from '@mikro-orm/core';
import { AuditLogRepository } from '../repositories/AuditLog.repository';
import { DbTimestampType } from '../types';
import { Users } from './Users.entity';

export class AuditLog {
  [EntityRepositoryType]?: AuditLogRepository;
  id!: number & Opt;
  created_at?: string | null;
  user?: Ref<Users> | null;
  user_id?: number | null;
  action!: string;
  resource?: string | null;
  details?: string | null;
  ip?: string | null;
}

export const AuditLogSchema = defineEntity({
  class: AuditLog,
  repository: () => AuditLogRepository,
  properties: {
    id: p.integer().primary(),
    created_at: p.type(DbTimestampType).nullable().defaultRaw(`CURRENT_TIMESTAMP`).index('idx_audit_log_created'),
    user: () => p.manyToOne(Users).ref().nullable().hidden().index('idx_audit_log_user_id'),
    user_id: p.integer().nullable().persist(false).index('idx_audit_log_user_id'),
    action: p.text(),
    resource: p.text().nullable(),
    details: p.text().nullable(),
    ip: p.text().nullable(),
  },
});