This commit is contained in:
24
src/models/Feed.ts
Normal file
24
src/models/Feed.ts
Normal file
@ -0,0 +1,24 @@
|
||||
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>[];
|
||||
}
|
11
src/models/Post.ts
Normal file
11
src/models/Post.ts
Normal file
@ -0,0 +1,11 @@
|
||||
import { PrimaryColumn, Entity, ManyToOne, Relation } from "typeorm";
|
||||
import { Feed } from "./Feed.js";
|
||||
|
||||
@Entity()
|
||||
export class Post {
|
||||
@PrimaryColumn()
|
||||
hash: string;
|
||||
|
||||
@ManyToOne(() => Feed, (feed) => feed.oldEntries)
|
||||
feed: Relation<Feed>;
|
||||
}
|
15
src/models/User.ts
Normal file
15
src/models/User.ts
Normal file
@ -0,0 +1,15 @@
|
||||
import { PrimaryGeneratedColumn, ManyToMany, Relation, Entity, Column, Unique } from "typeorm"
|
||||
import { Feed } from "./Feed.js";
|
||||
|
||||
@Entity()
|
||||
@Unique("chatid", ["chatid"])
|
||||
export class User {
|
||||
@PrimaryGeneratedColumn()
|
||||
id: number;
|
||||
|
||||
@Column()
|
||||
chatid: number;
|
||||
|
||||
@ManyToMany(() => Feed, feed => feed.subscriber)
|
||||
feeds: Relation<Feed>[];
|
||||
}
|
Reference in New Issue
Block a user