mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-25 19:26:31 -05:00
AuthorEntity: Add missing properties
This adds the missing properties according to the DB PlantUML schema Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
parent
59a4c72299
commit
4e14053f8f
1 changed files with 44 additions and 4 deletions
|
@ -4,14 +4,54 @@
|
|||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import { Entity, PrimaryGeneratedColumn } from 'typeorm';
|
||||
import { Note } from '../notes/note.entity';
|
||||
import {
|
||||
Column,
|
||||
Entity,
|
||||
ManyToOne,
|
||||
OneToMany,
|
||||
PrimaryGeneratedColumn,
|
||||
} from 'typeorm';
|
||||
import { Authorship } from '../revisions/authorship.entity';
|
||||
import { Session } from '../users/session.entity';
|
||||
import { User } from '../users/user.entity';
|
||||
|
||||
export type AuthorColor = number;
|
||||
|
||||
/**
|
||||
* The author represents a single user editing a note.
|
||||
* A 'user' can either be a registered and logged-in user or a browser session identified by its cookie.
|
||||
* All edits (aka authorships) of one user in a note must belong to the same author, so that the same color can be displayed.
|
||||
*/
|
||||
@Entity()
|
||||
export class Author {
|
||||
//TODO: Still missing many properties
|
||||
@PrimaryGeneratedColumn()
|
||||
id: number;
|
||||
|
||||
note: Note;
|
||||
/**
|
||||
* The id of the color of this author
|
||||
* The application maps the id to an actual color
|
||||
*/
|
||||
@Column({ type: 'int' })
|
||||
color: AuthorColor;
|
||||
|
||||
/**
|
||||
* A list of (browser) sessions this author has
|
||||
* Only contains sessions for anonymous users, which don't have a user set
|
||||
*/
|
||||
@OneToMany(() => Session, (session) => session.author)
|
||||
sessions: Session[];
|
||||
|
||||
/**
|
||||
* User that this author corresponds to
|
||||
* Only set when the user was identified (by a browser session) as a registered user at edit-time
|
||||
*/
|
||||
@ManyToOne(() => User, (user) => user.authors, { nullable: true })
|
||||
user: User | null;
|
||||
|
||||
/**
|
||||
* List of authorships that this author created
|
||||
* All authorships must belong to the same note
|
||||
*/
|
||||
@OneToMany(() => Authorship, (authorship) => authorship.author)
|
||||
authorships: Authorship[];
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue