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:
David Mehren 2020-08-12 20:51:49 +02:00
parent 31fbe390c7
commit 0a33d8ef8d
No known key found for this signature in database
GPG key ID: 185982BA4C42B7C3
2 changed files with 47 additions and 1 deletions

View 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
}

View file

@ -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],
})