bak.
This commit is contained in:
@ -14,6 +14,7 @@ import { UpdateArticleInput } from './dto/update-article.input';
|
||||
import * as marked from 'marked';
|
||||
import highlight from 'highlight.js';
|
||||
import { AccountRole, Roles } from '@nestjs-lib/auth';
|
||||
import { ArticleHistory } from './models/article-history.model';
|
||||
|
||||
@Resolver(() => Article)
|
||||
export class ArticlesResolver {
|
||||
@ -81,4 +82,9 @@ export class ArticlesResolver {
|
||||
|
||||
return token?.text;
|
||||
}
|
||||
|
||||
@ResolveField(() => [ArticleHistory])
|
||||
async histories(@Parent() article: Article) {
|
||||
return article.histories;
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { ObjectType } from '@nestjs/graphql';
|
||||
import { ArticleHistory } from './../models/article-history.model';
|
||||
import { HideField, ObjectType } from '@nestjs/graphql';
|
||||
import { Column, Entity, Index } from 'typeorm';
|
||||
import { AppBaseEntity } from '../../commons/entities/app-base-entity';
|
||||
|
||||
@ -17,4 +18,8 @@ export class Article extends AppBaseEntity {
|
||||
|
||||
@Column({ type: 'varchar', array: true })
|
||||
tags: string[];
|
||||
|
||||
@HideField()
|
||||
@Column({ type: 'jsonb', default: [] })
|
||||
histories: ArticleHistory[];
|
||||
}
|
||||
|
15
src/articles/models/article-history.model.ts
Normal file
15
src/articles/models/article-history.model.ts
Normal file
@ -0,0 +1,15 @@
|
||||
import { Column } from 'typeorm';
|
||||
import { ObjectType, Field } from '@nestjs/graphql';
|
||||
import { Article } from '../entities/article.entity';
|
||||
|
||||
@ObjectType()
|
||||
export class ArticleHistory {
|
||||
@Field(() => Object)
|
||||
payload: Partial<Article>;
|
||||
|
||||
updatedAt: Date;
|
||||
|
||||
automatic: boolean;
|
||||
|
||||
published: boolean;
|
||||
}
|
Reference in New Issue
Block a user