Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { Document, Schema as MongooseSchema, Types } from 'mongoose';
@Schema({ timestamps: true, collection: 'knowledge_articles' })
export class KnowledgeArticle extends Document {
@Prop({ type: MongooseSchema.Types.ObjectId, required: true, index: true })
tenantId: MongooseSchema.Types.ObjectId;
@Prop({ type: MongooseSchema.Types.ObjectId, ref: 'KnowledgeCategory', required: true, index: true })
categoryId: MongooseSchema.Types.ObjectId;
@Prop({ required: true })
title: string;
@Prop({ required: true })
slug: string;
@Prop({ default: '' })
summary: string;
@Prop({ required: true })
content: string; // HTML CKEditor format
@Prop({ default: 'draft', index: true })
status: string; // 'draft' | 'review' | 'approval' | 'published' | 'deprecated' | 'archived'
@Prop({ type: [String], default: [] })
tags: string[];
@Prop({ type: [String], default: [] })
keywords: string[];
@Prop({ default: 1 })
majorVersion: number;
@Prop({ default: 0 })
minorVersion: number;
@Prop({ type: MongooseSchema.Types.ObjectId, ref: 'Employee', index: true })
ownerId?: MongooseSchema.Types.ObjectId;
@Prop({ type: MongooseSchema.Types.ObjectId, ref: 'Employee' })
approverId?: MongooseSchema.Types.ObjectId;
@Prop()
expiryDate?: Date;
@Prop({ default: 0 })
estimatedReadTimeMinutes: number;
@Prop({ default: '' })
aiSummary?: string;
@Prop({ type: [String], default: [] })
aiKeywords?: string[];
@Prop({ type: [String], default: [] })
attachmentUrls?: string[];
}
export const KnowledgeArticleSchema = SchemaFactory.createForClass(KnowledgeArticle);
KnowledgeArticleSchema.index({ tenantId: 1, slug: 1 }, { unique: true });
KnowledgeArticleSchema.index({ tenantId: 1, status: 1 });
@Schema({ timestamps: true, collection: 'knowledge_article_versions' })
export class KnowledgeArticleVersion extends Document {
@Prop({ type: MongooseSchema.Types.ObjectId, required: true, index: true })
tenantId: MongooseSchema.Types.ObjectId;
@Prop({ type: MongooseSchema.Types.ObjectId, ref: 'KnowledgeArticle', required: true, index: true })
articleId: MongooseSchema.Types.ObjectId;
@Prop({ required: true })
title: string;
@Prop({ required: true })
content: string;
@Prop({ required: true })
majorVersion: number;
@Prop({ required: true })
minorVersion: number;
@Prop({ required: true })
changeLog: string;
@Prop({ type: MongooseSchema.Types.ObjectId, ref: 'Employee' })
createdBy: MongooseSchema.Types.ObjectId;
}
export const KnowledgeArticleVersionSchema = SchemaFactory.createForClass(KnowledgeArticleVersion);
KnowledgeArticleVersionSchema.index({ tenantId: 1, articleId: 1, majorVersion: 1, minorVersion: 1 }, { unique: true });
|