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 { VacayUserColorsRepository } from '../repositories/VacayUserColors.repository';
import { Users } from './Users.entity';
import { VacayPlans } from './VacayPlans.entity';

export class VacayUserColors {
  [EntityRepositoryType]?: VacayUserColorsRepository;
  id!: number & Opt;
  user!: Ref<Users>;
  user_id!: number;
  plan!: Ref<VacayPlans>;
  plan_id!: number;
  color?: string | null = '#6366f1';
}

export const VacayUserColorsSchema = defineEntity({
  class: VacayUserColors,
  repository: () => VacayUserColorsRepository,
  uniques: [{ properties: ['user', 'plan'] }],
  properties: {
    id: p.integer().primary(),
    user: () => p.manyToOne(Users).ref().deleteRule('cascade').hidden(),
    user_id: p.integer().persist(false),
    plan: () => p.manyToOne(VacayPlans).ref().deleteRule('cascade').hidden().index('idx_vacay_user_colors_plan_id'),
    plan_id: p.integer().persist(false).index('idx_vacay_user_colors_plan_id'),
    color: p.text().nullable(),
  },
});