mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-25 03:06:31 -05:00
Add authorship entity.
It stores which parts of a revision were edited by a particular user. Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
parent
31fbe390c7
commit
0a33d8ef8d
2 changed files with 47 additions and 1 deletions
45
src/revisions/authorship.entity.ts
Normal file
45
src/revisions/authorship.entity.ts
Normal file
|
@ -0,0 +1,45 @@
|
|||
import {
|
||||
Column, CreateDateColumn,
|
||||
Entity,
|
||||
ManyToMany,
|
||||
ManyToOne,
|
||||
PrimaryGeneratedColumn, UpdateDateColumn,
|
||||
} from 'typeorm/index';
|
||||
import { User } from '../users/user.entity';
|
||||
import { Revision } from './revision.entity';
|
||||
|
||||
/**
|
||||
* This class stores which parts of a revision were edited by a particular user.
|
||||
*/
|
||||
@Entity()
|
||||
export class Authorship {
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
id: string;
|
||||
|
||||
/**
|
||||
* Revisions this authorship appears in
|
||||
*/
|
||||
@ManyToMany(
|
||||
_ => Revision,
|
||||
revision => revision.authorships,
|
||||
)
|
||||
revisions: Revision[];
|
||||
|
||||
/**
|
||||
* User this authorship represents
|
||||
*/
|
||||
@ManyToOne(_ => User)
|
||||
user: User;
|
||||
|
||||
@Column()
|
||||
startPos: number
|
||||
|
||||
@Column()
|
||||
endPos: number
|
||||
|
||||
@CreateDateColumn()
|
||||
createdAt: Date
|
||||
|
||||
@UpdateDateColumn()
|
||||
updatedAt: Date
|
||||
}
|
|
@ -1,10 +1,11 @@
|
|||
import { Module } from '@nestjs/common';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { Authorship } from './authorship.entity';
|
||||
import { Revision } from './revision.entity';
|
||||
import { RevisionsService } from './revisions.service';
|
||||
|
||||
@Module({
|
||||
imports: [TypeOrmModule.forFeature([Revision])],
|
||||
imports: [TypeOrmModule.forFeature([Revision, Authorship])],
|
||||
providers: [RevisionsService],
|
||||
exports: [RevisionsService],
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue