print module
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
import { Entity, Property, ManyToOne, PrimaryKey, Unique } from '@mikro-orm/core';
|
||||
import { BaseEntity } from '../../../common/entities/base.entity';
|
||||
import { Field } from './field.entity';
|
||||
|
||||
@Entity({ tableName: 'field_option' })
|
||||
export class FieldOption extends BaseEntity {
|
||||
@PrimaryKey({ autoincrement: true, type: 'bigint' })
|
||||
id: bigint;
|
||||
|
||||
@Property()
|
||||
value: string;
|
||||
|
||||
@ManyToOne(() => Field)
|
||||
field: Field;
|
||||
|
||||
@Property({ type: 'int', nullable: true })
|
||||
order?: number;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
import { Collection, Entity, Enum, ManyToOne, OneToMany, PrimaryKey, Property } from '@mikro-orm/core';
|
||||
import { FieldOption } from './field-option.entity';
|
||||
import { FieldType } from '../interface/print';
|
||||
import { Section } from './section.entity';
|
||||
|
||||
|
||||
@Entity({ tableName: 'field' })
|
||||
export class Field {
|
||||
@PrimaryKey({ type: 'bigint', autoincrement: true })
|
||||
id: bigint
|
||||
|
||||
@OneToMany(() => FieldOption, (attrValue) => attrValue.field)
|
||||
options = new Collection<FieldOption>(this)
|
||||
|
||||
@ManyToOne(() => Section)
|
||||
section: Section
|
||||
|
||||
@Property()
|
||||
name: string;
|
||||
|
||||
@Enum(() => FieldType)
|
||||
type: FieldType;
|
||||
|
||||
@Property({ type: 'boolean', default: false })
|
||||
isRequired: boolean = false;
|
||||
|
||||
@Property({ type: 'int', nullable: true })
|
||||
order?: number;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import { Cascade, Collection, Entity, OneToMany, PrimaryKey, Property } from '@mikro-orm/core';
|
||||
import { Field } from './field.entity';
|
||||
|
||||
|
||||
@Entity({ tableName: 'section' })
|
||||
export class Section {
|
||||
@PrimaryKey({ type: 'bigint', autoincrement: true })
|
||||
id: bigint
|
||||
|
||||
@OneToMany(() => Field, (attrValue) => attrValue.section, { cascade: [Cascade.PERSIST, Cascade.REMOVE] })
|
||||
Fields = new Collection<Field>(this)
|
||||
|
||||
@Property()
|
||||
title: string;
|
||||
|
||||
|
||||
@Property({ type: 'int', nullable: true })
|
||||
order?: number;
|
||||
}
|
||||
Reference in New Issue
Block a user