mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-24 20:14:35 -04:00
AuthorshipEntity: Adjust to DB schema
This commit replaces the user property with a author property,
in accordance with the DB schema updated in 0d6c3002
.
It also adjusts the NoteService accordingly.
Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
parent
27c2bfb36f
commit
20006df82f
3 changed files with 25 additions and 11 deletions
|
@ -13,11 +13,11 @@ import {
|
|||
PrimaryGeneratedColumn,
|
||||
UpdateDateColumn,
|
||||
} from 'typeorm';
|
||||
import { User } from '../users/user.entity';
|
||||
import { Author } from '../authors/author.entity';
|
||||
import { Revision } from './revision.entity';
|
||||
|
||||
/**
|
||||
* This class stores which parts of a revision were edited by a particular user.
|
||||
* The Authorship represents a change in the content of a note by a particular {@link Author}
|
||||
*/
|
||||
@Entity()
|
||||
export class Authorship {
|
||||
|
@ -31,10 +31,10 @@ export class Authorship {
|
|||
revisions: Revision[];
|
||||
|
||||
/**
|
||||
* User this authorship represents
|
||||
* Author that created the change
|
||||
*/
|
||||
@ManyToOne((_) => User)
|
||||
user: User;
|
||||
@ManyToOne(() => Author, (author) => author.authorships)
|
||||
author: Author;
|
||||
|
||||
@Column()
|
||||
startPos: number;
|
||||
|
@ -47,4 +47,15 @@ export class Authorship {
|
|||
|
||||
@UpdateDateColumn()
|
||||
updatedAt: Date;
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
||||
private constructor() {}
|
||||
|
||||
public static create(author: Author, startPos: number, endPos: number) {
|
||||
const newAuthorship = new Authorship();
|
||||
newAuthorship.author = author;
|
||||
newAuthorship.startPos = startPos;
|
||||
newAuthorship.endPos = endPos;
|
||||
return newAuthorship;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue