communication type typing

This commit is contained in:
Julian Krauser 2024-09-18 09:43:02 +02:00
parent f673dec5fa
commit 72c47ba212
5 changed files with 34 additions and 8 deletions

View file

@ -1,5 +1,6 @@
import { Column, Entity, OneToMany, PrimaryColumn } from "typeorm";
import { communication } from "./communication";
import { CommunicationFieldType, communicationFieldTypes } from "../type/fieldTypes";
@Entity()
export class communicationType {
@ -14,15 +15,15 @@ export class communicationType {
length: 255,
default: "",
transformer: {
from(value: string): Array<string> {
return (value ?? "").split(",");
from(value: string): Array<CommunicationFieldType> {
return communicationFieldTypes.filter((e) => value?.includes(e));
},
to(value: Array<string>): string {
return (value ?? []).join(",");
to(value: Array<CommunicationFieldType>): string {
return value.filter((e) => communicationFieldTypes.includes(e)).join(",");
},
},
})
useColumns: Array<string>;
useColumns: Array<CommunicationFieldType>;
@OneToMany(() => communication, (communication) => communication.type)
communications: communication[];