32 lines
680 B
TypeScript
32 lines
680 B
TypeScript
|
import {
|
||
|
Entity,
|
||
|
Column,
|
||
|
PrimaryColumn,
|
||
|
Index,
|
||
|
ManyToOne,
|
||
|
OneToMany,
|
||
|
} from "typeorm";
|
||
|
import { Account } from "./account.js";
|
||
|
import { Post } from "./post.js";
|
||
|
|
||
|
@Entity()
|
||
|
@Index(["username", "host"], { unique: true })
|
||
|
export class Blog {
|
||
|
@PrimaryColumn("text")
|
||
|
id: string;
|
||
|
@Column("text", { nullable: false })
|
||
|
username: string;
|
||
|
@Column("text", { nullable: true })
|
||
|
host: string | null;
|
||
|
|
||
|
@ManyToOne(() => Account, (account) => account.blogs)
|
||
|
account: Account;
|
||
|
@OneToMany(() => Post, (post) => post.blog)
|
||
|
posts: Post[];
|
||
|
|
||
|
@Column("text", { nullable: false })
|
||
|
publicKey: string;
|
||
|
@Column("text", { nullable: true })
|
||
|
privateKey: string | null;
|
||
|
}
|