summaryrefslogtreecommitdiff
path: root/packages/backend/src/models/NoteEdit.ts
blob: 449c974d52936129c3f882fa1973835e0c9e807e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
 * SPDX-FileCopyrightText: marie and other Sharkey contributors
 * SPDX-License-Identifier: AGPL-3.0-only
 */

import { Entity, JoinColumn, Column, ManyToOne, PrimaryColumn, Index } from 'typeorm';
import { id } from './util/id.js';
import { MiNote } from './Note.js';
import type { MiDriveFile } from './DriveFile.js';

@Entity()
export class NoteEdit {
	@PrimaryColumn(id())
	public id: string;

	@Index()
	@Column({
		...id(),
		comment: 'The ID of note.',
	})
	public noteId: MiNote['id'];

	@ManyToOne(() => MiNote, {
		onDelete: 'CASCADE',
	})
	@JoinColumn()
	public note: MiNote | null;

	@Column('text', {
		nullable: true,
	})
	public newText: string | null;

	@Column('varchar', {
		length: 512,
		nullable: true,
	})
	public cw: string | null;

	@Column({
		...id(),
		array: true,
		default: '{}',
	})
	public fileIds: MiDriveFile['id'][];

	@Column('timestamp with time zone', {
		comment: 'The updated date of the Note.',
	})
	public updatedAt: Date;

	@Column('text', {
		nullable: true,
	})
	public oldText: string | null;

	@Column('timestamp with time zone', {
		comment: 'The old date from before the edit',
		nullable: true,
	})
	public oldDate: Date | null;
}