import { Column, Entity, PrimaryColumn } from 'typeorm';
import {
  encodeBigNumberKey,
  decodeBigNumberKey,
} from '../utils/big-number-key';

@Entity('asset_block_keys', { schema: 'public' })
export class AssetBlockKeyEntity {
  @PrimaryColumn('bigint', {
    name: 'project_id',
    nullable: false,
    transformer: {
      from: (x) => encodeBigNumberKey(x),
      to: (x) => decodeBigNumberKey(x),
    },
  })
  projectId: string;

  @PrimaryColumn('bigint', {
    name: 'block_key',
    nullable: false,
  })
  blockKey: string;

  @Column('varchar', {
    name: 'block_name',
    nullable: false,
  })
  blockName: string;

  @Column('varchar', {
    name: 'block_title',
    nullable: false,
  })
  blockTitle: string;

  @Column('varchar', {
    name: 'block_type',
    nullable: false,
  })
  blockType: string;
}
