Commit With Frontend and Backend in MERN
This commit is contained in:
54
backend/node_modules/mongodb/src/operations/search_indexes/create.ts
generated
vendored
Normal file
54
backend/node_modules/mongodb/src/operations/search_indexes/create.ts
generated
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
import type { Document } from '../../bson';
|
||||
import type { Collection } from '../../collection';
|
||||
import type { Server } from '../../sdam/server';
|
||||
import type { ClientSession } from '../../sessions';
|
||||
import { type TimeoutContext } from '../../timeout';
|
||||
import { AbstractOperation } from '../operation';
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export interface SearchIndexDescription extends Document {
|
||||
/** The name of the index. */
|
||||
name?: string;
|
||||
|
||||
/** The index definition. */
|
||||
definition: Document;
|
||||
|
||||
/** The type of the index. Currently `search` or `vectorSearch` are supported. */
|
||||
type?: string;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export class CreateSearchIndexesOperation extends AbstractOperation<string[]> {
|
||||
constructor(
|
||||
private readonly collection: Collection,
|
||||
private readonly descriptions: ReadonlyArray<SearchIndexDescription>
|
||||
) {
|
||||
super();
|
||||
}
|
||||
|
||||
override get commandName() {
|
||||
return 'createSearchIndexes' as const;
|
||||
}
|
||||
|
||||
override async execute(
|
||||
server: Server,
|
||||
session: ClientSession | undefined,
|
||||
timeoutContext: TimeoutContext
|
||||
): Promise<string[]> {
|
||||
const namespace = this.collection.fullNamespace;
|
||||
const command = {
|
||||
createSearchIndexes: namespace.collection,
|
||||
indexes: this.descriptions
|
||||
};
|
||||
|
||||
const res = await server.command(namespace, command, {
|
||||
session,
|
||||
timeoutContext
|
||||
});
|
||||
|
||||
const indexesCreated: Array<{ name: string }> = res?.indexesCreated ?? [];
|
||||
return indexesCreated.map(({ name }) => name);
|
||||
}
|
||||
}
|
||||
47
backend/node_modules/mongodb/src/operations/search_indexes/drop.ts
generated
vendored
Normal file
47
backend/node_modules/mongodb/src/operations/search_indexes/drop.ts
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
import type { Document } from '../../bson';
|
||||
import type { Collection } from '../../collection';
|
||||
import { MONGODB_ERROR_CODES, MongoServerError } from '../../error';
|
||||
import type { Server } from '../../sdam/server';
|
||||
import type { ClientSession } from '../../sessions';
|
||||
import { type TimeoutContext } from '../../timeout';
|
||||
import { AbstractOperation } from '../operation';
|
||||
|
||||
/** @internal */
|
||||
export class DropSearchIndexOperation extends AbstractOperation<void> {
|
||||
constructor(
|
||||
private readonly collection: Collection,
|
||||
private readonly name: string
|
||||
) {
|
||||
super();
|
||||
}
|
||||
|
||||
override get commandName() {
|
||||
return 'dropSearchIndex' as const;
|
||||
}
|
||||
|
||||
override async execute(
|
||||
server: Server,
|
||||
session: ClientSession | undefined,
|
||||
timeoutContext: TimeoutContext
|
||||
): Promise<void> {
|
||||
const namespace = this.collection.fullNamespace;
|
||||
|
||||
const command: Document = {
|
||||
dropSearchIndex: namespace.collection
|
||||
};
|
||||
|
||||
if (typeof this.name === 'string') {
|
||||
command.name = this.name;
|
||||
}
|
||||
|
||||
try {
|
||||
await server.command(namespace, command, { session, timeoutContext });
|
||||
} catch (error) {
|
||||
const isNamespaceNotFoundError =
|
||||
error instanceof MongoServerError && error.code === MONGODB_ERROR_CODES.NamespaceNotFound;
|
||||
if (!isNamespaceNotFoundError) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
37
backend/node_modules/mongodb/src/operations/search_indexes/update.ts
generated
vendored
Normal file
37
backend/node_modules/mongodb/src/operations/search_indexes/update.ts
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
import type { Document } from '../../bson';
|
||||
import type { Collection } from '../../collection';
|
||||
import type { Server } from '../../sdam/server';
|
||||
import type { ClientSession } from '../../sessions';
|
||||
import { type TimeoutContext } from '../../timeout';
|
||||
import { AbstractOperation } from '../operation';
|
||||
|
||||
/** @internal */
|
||||
export class UpdateSearchIndexOperation extends AbstractOperation<void> {
|
||||
constructor(
|
||||
private readonly collection: Collection,
|
||||
private readonly name: string,
|
||||
private readonly definition: Document
|
||||
) {
|
||||
super();
|
||||
}
|
||||
|
||||
override get commandName() {
|
||||
return 'updateSearchIndex' as const;
|
||||
}
|
||||
|
||||
override async execute(
|
||||
server: Server,
|
||||
session: ClientSession | undefined,
|
||||
timeoutContext: TimeoutContext
|
||||
): Promise<void> {
|
||||
const namespace = this.collection.fullNamespace;
|
||||
const command = {
|
||||
updateSearchIndex: namespace.collection,
|
||||
name: this.name,
|
||||
definition: this.definition
|
||||
};
|
||||
|
||||
await server.command(namespace, command, { session, timeoutContext });
|
||||
return;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user