import { Entity, Unique, PrimaryGeneratedColumn, Column, ManyToMany, JoinTable, OneToMany, Relation } from "typeorm";
import { User } from "./User.js";
import { Post } from "./Post.js";

@Entity()
export class Feed {
   @PrimaryGeneratedColumn()
   id: number;

   @Column()
   url: string;

   @Column({
      default: "1970-01-01 01:00:00.000"
   })
   lastCheck?: Date;

   @ManyToMany(() => User, user => user.feeds)
   @JoinTable()
   subscriber: Relation<User>[];

   @OneToMany(() => Post, post => post.feed)
   oldEntries: Relation<Post>[];
}