import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { Document, Types } from 'mongoose';
import moment from 'moment';
import { KnowledgeBase } from './knowledge_base.schema';

@Schema()
export class Documents extends Document {

  @Prop({ type: Types.ObjectId, ref: KnowledgeBase.name, default: null })
  knowledge_base_id: Types.ObjectId

  @Prop({ type: String, default: 'PDF' })
  type: string = null;

  @Prop({ type: String, default: null })
  name: string;

  @Prop({ type: String, default: null })
  url: string;

  @Prop({ type: String, default: null })
  document_title: string;

  @Prop({ type: String, default: null })
  content: string;

  @Prop({ type: [String], default: [] })
  document_ids: string[];

  @Prop({ default: moment().utc().valueOf() })
  updated_at: number = moment().utc().valueOf();

  @Prop({ default: moment().utc().valueOf() })
  created_at: number = moment().utc().valueOf();
}

export const documentSchema = SchemaFactory.createForClass(Documents);
