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 | import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; import { Document, Schema as MongooseSchema } from 'mongoose'; @Schema({ collection: 'search_index_definitions', timestamps: true }) export class SearchIndexDefinition extends Document { @Prop({ required: true, unique: true }) entityType!: string; @Prop({ required: true }) collectionName!: string; @Prop({ type: [String], required: true }) searchableFields!: string[]; @Prop({ type: [String], default: [] }) filterableFields!: string[]; @Prop({ type: [String], default: [] }) sortableFields!: string[]; @Prop({ default: true }) isActive!: boolean; @Prop() lastReindexAt?: Date; @Prop({ default: 0 }) totalDocuments!: number; } export const SearchIndexDefinitionSchema = SchemaFactory.createForClass( SearchIndexDefinition, ); @Schema({ collection: 'search_sync_cursors', timestamps: true }) export class SearchSyncCursor extends Document { @Prop({ type: MongooseSchema.Types.ObjectId, required: true, index: true }) tenantId!: MongooseSchema.Types.ObjectId; @Prop({ required: true }) entityType!: string; @Prop() lastSyncedId?: string; @Prop() lastSyncedAt?: Date; @Prop({ default: 'idle', enum: ['idle', 'syncing', 'failed'] }) status!: string; } export const SearchSyncCursorSchema = SchemaFactory.createForClass(SearchSyncCursor); SearchSyncCursorSchema.index({ tenantId: 1, entityType: 1 }, { unique: true }); @Schema({ collection: 'search_query_logs', timestamps: true }) export class SearchQueryLog extends Document { @Prop({ type: MongooseSchema.Types.ObjectId, required: true, index: true }) tenantId!: MongooseSchema.Types.ObjectId; @Prop({ type: MongooseSchema.Types.ObjectId }) userId?: MongooseSchema.Types.ObjectId; @Prop({ required: true }) query!: string; @Prop({ type: [String], default: [] }) entityTypes!: string[]; @Prop({ default: 0 }) resultCount!: number; @Prop({ default: 0 }) durationMs!: number; @Prop() selectedResultId?: string; } export const SearchQueryLogSchema = SchemaFactory.createForClass(SearchQueryLog); |