import { UserEntity } from 'modules/user/entity/users.entity';
import { Column, CreateDateColumn, Entity, JoinColumn, ManyToOne, PrimaryGeneratedColumn } from 'typeorm';

@Entity('library')
export class LibraryEntity {
  @PrimaryGeneratedColumn()
  id: number;

  @Column({ name: 'attachment_url', nullable: true })
  attachmentUrl: string;

  @Column({ name: 'attachment_name', nullable: true })
  attachmentName: string;

  @Column({ name: 'attachment_type', nullable: true })
  attachmentType: string;

  @Column({ name: 'attachment_size', nullable: true })
  attachmentSize: string;

  @Column({ name: 'attachment_description', nullable: true })
  attachmentDescription: string;

  @Column({ name: 'attachment_category', nullable: true })
  attachmentCategory: string;

  @ManyToOne(() => UserEntity, { nullable: true })
  @JoinColumn({ name: 'attachment_posted_by' })
  attachmentPostedBy: UserEntity;

  @Column({ name: 'is_public', default: false })
  isPublic: boolean;

  @Column('simple-array', { name: 'tags', nullable: true })
  tags: string[];

  @Column({ name: 'is_active', default: true })
  isActive: boolean;

  @CreateDateColumn({ name: 'created_at' })
  createdAt: Date;

  @CreateDateColumn({ name: 'updated_at' })
  updatedAt: Date;
}
