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 { Db } from '../db';5import { CommandOperation, type CommandOperationOptions } from './command';6import { Aspect, defineAspects } from './operation';7 8/** @public */9export interface DbStatsOptions extends Omit<CommandOperationOptions, 'rawData'> {10 /** Divide the returned sizes by scale value. */11 scale?: number;12}13 14/** @internal */15export class DbStatsOperation extends CommandOperation<Document> {16 override SERVER_COMMAND_RESPONSE_TYPE = MongoDBResponse;17 override options: DbStatsOptions;18 19 constructor(db: Db, options: DbStatsOptions) {20 super(db, options);21 this.options = options;22 }23 24 override get commandName() {25 return 'dbStats' as const;26 }27 28 override buildCommandDocument(_connection: Connection): Document {29 const command: Document = { dbStats: true };30 if (this.options.scale != null) {31 command.scale = this.options.scale;32 }33 return command;34 }35}36 37defineAspects(DbStatsOperation, [Aspect.READ_OPERATION]);38 