diff options
| author | syuilo <Syuilotan@yahoo.co.jp> | 2020-02-18 08:41:32 +0900 |
|---|---|---|
| committer | syuilo <Syuilotan@yahoo.co.jp> | 2020-02-18 08:41:32 +0900 |
| commit | a54de07260c3555d0230492970448604ffb9d586 (patch) | |
| tree | 0650c5de48af1cd5b5945da6a3dff6093ceaefd1 /src/models/entities | |
| parent | Fix type (diff) | |
| download | misskey-a54de07260c3555d0230492970448604ffb9d586.tar.gz misskey-a54de07260c3555d0230492970448604ffb9d586.tar.bz2 misskey-a54de07260c3555d0230492970448604ffb9d586.zip | |
Resolve #5963
Diffstat (limited to 'src/models/entities')
| -rw-r--r-- | src/models/entities/promo-note.ts | 28 | ||||
| -rw-r--r-- | src/models/entities/promo-read.ts | 35 |
2 files changed, 63 insertions, 0 deletions
diff --git a/src/models/entities/promo-note.ts b/src/models/entities/promo-note.ts new file mode 100644 index 0000000000..474f1cb235 --- /dev/null +++ b/src/models/entities/promo-note.ts @@ -0,0 +1,28 @@ +import { PrimaryColumn, Entity, Index, JoinColumn, Column, OneToOne } from 'typeorm'; +import { Note } from './note'; +import { User } from './user'; +import { id } from '../id'; + +@Entity() +export class PromoNote { + @PrimaryColumn(id()) + public noteId: Note['id']; + + @OneToOne(type => Note, { + onDelete: 'CASCADE' + }) + @JoinColumn() + public note: Note | null; + + @Column('timestamp with time zone') + public expiresAt: Date; + + //#region Denormalized fields + @Index() + @Column({ + ...id(), + comment: '[Denormalized]' + }) + public userId: User['id']; + //#endregion +} diff --git a/src/models/entities/promo-read.ts b/src/models/entities/promo-read.ts new file mode 100644 index 0000000000..2e0977b6b5 --- /dev/null +++ b/src/models/entities/promo-read.ts @@ -0,0 +1,35 @@ +import { PrimaryColumn, Entity, Index, JoinColumn, Column, ManyToOne } from 'typeorm'; +import { Note } from './note'; +import { User } from './user'; +import { id } from '../id'; + +@Entity() +@Index(['userId', 'noteId'], { unique: true }) +export class PromoRead { + @PrimaryColumn(id()) + public id: string; + + @Column('timestamp with time zone', { + comment: 'The created date of the PromoRead.' + }) + public createdAt: Date; + + @Index() + @Column(id()) + public userId: User['id']; + + @ManyToOne(type => User, { + onDelete: 'CASCADE' + }) + @JoinColumn() + public user: User | null; + + @Column(id()) + public noteId: Note['id']; + + @ManyToOne(type => Note, { + onDelete: 'CASCADE' + }) + @JoinColumn() + public note: Note | null; +} |