-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathupdate.ts
More file actions
45 lines (39 loc) · 1.47 KB
/
update.ts
File metadata and controls
45 lines (39 loc) · 1.47 KB
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
import type { Document } from '../../bson';
import { type Connection } from '../../cmap/connection';
import { MongoDBResponse } from '../../cmap/wire_protocol/responses';
import type { Collection } from '../../collection';
import type { ServerCommandOptions } from '../../sdam/server';
import type { ClientSession } from '../../sessions';
import { type TimeoutContext } from '../../timeout';
import { ModernizedOperation } from '../operation';
/** @internal */
export class UpdateSearchIndexOperation extends ModernizedOperation<void> {
override SERVER_COMMAND_RESPONSE_TYPE = MongoDBResponse;
private readonly collection: Collection;
private readonly name: string;
private readonly definition: Document;
constructor(collection: Collection, name: string, definition: Document) {
super();
this.collection = collection;
this.name = name;
this.definition = definition;
this.ns = collection.fullNamespace;
}
override get commandName() {
return 'updateSearchIndex' as const;
}
override buildCommand(_connection: Connection, _session?: ClientSession): Document {
const namespace = this.collection.fullNamespace;
return {
updateSearchIndex: namespace.collection,
name: this.name,
definition: this.definition
};
}
override handleOk(_response: MongoDBResponse): void {
// no response.
}
override buildOptions(timeoutContext: TimeoutContext): ServerCommandOptions {
return { session: this.session, timeoutContext };
}
}