import { Entity, Column, PrimaryGeneratedColumn, OneToOne, JoinColumn, OneToMany, CreateDateColumn, UpdateDateColumn, DeleteDateColumn, ManyToMany, JoinTable, ManyToOne, Unique } from 'typeorm';
import { v4 as uuidv4 } from 'uuid';
import { Exclude, Expose } from 'class-transformer';
import { Users } from './users.entity';
import { CountryListInstance } from 'twilio/lib/rest/pricing/v2/voice/country';
import { SocialMedias } from './social-medias.entity';
import { YoutubeChannels } from './youtube-channel.entity';



@Entity({ name: 'youtube_videos' })
export class YoutubeVideos {

  @PrimaryGeneratedColumn('uuid')
  id: string;

  @ManyToOne(() => Users, user => user.id, { nullable: true })
  @JoinColumn({ name: "users" })
  users: Users;

  @ManyToOne(() => SocialMedias, (socialMedia) => socialMedia.id)
  @JoinColumn({ name: "socialMedia" })
  socialMedia: SocialMedias;

  @ManyToOne(() => YoutubeChannels, (youtubeChannel) => youtubeChannel.id)
  @JoinColumn({ name: "youtubeChannel" })
  youtubeChannel: YoutubeChannels;

  @Column({ default: "" })
  title: string;

  @Column({ type: 'text', default: "" })
  description: string;

  @Column({ type: 'text', default: "" })
  channel_name: string;

  @Column({ type: 'text', default: "" })
  published_at: string;

  @Column({ type: 'text', default: "" })
  thumbnails: string;

  @Column({ type: 'text', default: "" })
  localized: string;

  @Column({ type: 'text', default: "", comment: "Youtube Videos Id" })
  video_id: string;

  @Column({ type: 'text', nullable: true, comment: "Youtube Videos VIDEO URL" })
  post_url: string;

  @Column({ type: 'text', default: "", comment: "Youtube category Id" })
  youtube_category_id: string;

  @Column({ type: 'bigint', default: 0 })
  view_counts: string;

  @Column({ type: 'bigint', default: 0 })
  like_counts: string;

  @Column({ type: 'bigint', default: 0 })
  comment_count: string;

  @Column({ type: 'bigint', default: 0 })
  fevorite_count: string;

  @Exclude()
  @CreateDateColumn({
    type: 'timestamp',
    precision: 0,
    default: () => 'CURRENT_TIMESTAMP',
  })
  created_at: Date;

  @Exclude()
  @UpdateDateColumn({
    type: 'timestamp',
    precision: 0,
    default: () => 'CURRENT_TIMESTAMP',
    onUpdate: 'CURRENT_TIMESTAMP',
  })
  updated_at: Date;

  @Exclude()
  @DeleteDateColumn({ type: 'timestamp', nullable: true, precision: 0 })
  deleted_at: Date;

  setDefaults() {
    this.id = this.id || uuidv4();
  }
}