opusdev/vector-similarity-api
1
1import type { Document } from '../../bson';2import { type Connection } from '../../cmap/connection';3import { MongoDBResponse } from '../../cmap/wire_protocol/responses';4import type { Collection } from '../../collection';5import type { ServerCommandOptions } from '../../sdam/server';6import type { ClientSession } from '../../sessions';7import { type TimeoutContext } from '../../timeout';8import { AbstractOperation } from '../operation';9 10/** @internal */11export class UpdateSearchIndexOperation extends AbstractOperation<void> {12 override SERVER_COMMAND_RESPONSE_TYPE = MongoDBResponse;13 private readonly collection: Collection;14 private readonly name: string;15 private readonly definition: Document;16 17 constructor(collection: Collection, name: string, definition: Document) {18 super();19 this.collection = collection;20 this.name = name;21 this.definition = definition;22 this.ns = collection.fullNamespace;23 }24 25 override get commandName() {26 return 'updateSearchIndex' as const;27 }28 29 override buildCommand(_connection: Connection, _session?: ClientSession): Document {30 const namespace = this.collection.fullNamespace;31 return {32 updateSearchIndex: namespace.collection,33 name: this.name,34 definition: this.definition35 };36 }37 38 override handleOk(_response: MongoDBResponse): void {39 // no response.40 }41 42 override buildOptions(timeoutContext: TimeoutContext): ServerCommandOptions {43 return { session: this.session, timeoutContext };44 }45}46 