import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm';
import { PolygonExtremes, PolygonPayload } from '../features/polygon';

@Entity('polygons')
export class PolygonEntity {
    @PrimaryGeneratedColumn() id: number;
    @Column({ type: 'varchar', length: 64 }) name: string;
    @Column({ type: 'varchar', length: 512 }) tags: string;
    @Column({ type: 'json' }) payload: PolygonPayload;
    @Column({ type: 'json' }) extremes: PolygonExtremes;
    @Column({ type: 'json', nullable: true }) location: {
        x: number;
        y: number;
        z: number;
    };
    @Column() created_by: number;
    @Column({ type: 'datetime', default: () => 'CURRENT_TIMESTAMP' }) created: Date;
}
