Add event source code to models

This commit is contained in:
ssmucny 2023-04-13 19:31:27 -04:00
parent 0db88a5a3b
commit c7e607ea5f
2 changed files with 49 additions and 1 deletions

View File

@ -0,0 +1,33 @@
import { Entity, Index, Column, PrimaryColumn } from 'typeorm';
import { id } from '../id.js';
@Entity()
export class Event {
@PrimaryColumn(id())
public id: string;
@Index()
@Column('timestamp with time zone', {
comment: 'The start time of the event',
})
public start: Date;
@Column('timestamp with time zone', {
comment: 'The end of the event',
nullable: true,
})
public end: Date;
@Column({
type: 'varchar',
length: 128,
comment: 'short name of event',
})
public title: string;
@Column('jsonb', {
default: {},
comment: 'metadata mapping for event with more user configurable optional information',
})
public metadata: Record<string, string>;
}

View File

@ -1,8 +1,9 @@
import { Entity, Index, JoinColumn, Column, PrimaryColumn, ManyToOne } from 'typeorm';
import { Entity, Index, JoinColumn, Column, PrimaryColumn, ManyToOne, OneToOne } from 'typeorm';
import { id } from '../id.js';
import { noteVisibilities } from '../../types.js';
import { User } from './User.js';
import { Channel } from './Channel.js';
import { Event } from './Event.js';
import type { DriveFile } from './DriveFile.js';
@Entity()
@ -53,6 +54,20 @@ export class Note {
})
public threadId: string | null;
@Index()
@Column({
...id(),
nullable: true,
comment: 'id of child event',
})
public noteId: Event['id'] | null;
@OneToOne(type => Event, {
onDelete: 'CASCADE',
})
@JoinColumn()
public note: Event | null;
// TODO: varcharにしたい
@Column('text', {
nullable: true,