/
list_indexes_cursor.ts
38 lines (32 loc) · 1.17 KB
/
list_indexes_cursor.ts
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
import type { Collection } from '../collection';
import { executeOperation, type ExecutionResult } from '../operations/execute_operation';
import { ListIndexesOperation, type ListIndexesOptions } from '../operations/indexes';
import type { ClientSession } from '../sessions';
import { AbstractCursor } from './abstract_cursor';
/** @public */
export class ListIndexesCursor extends AbstractCursor {
parent: Collection;
options?: ListIndexesOptions;
constructor(collection: Collection, options?: ListIndexesOptions) {
super(collection.client, collection.s.namespace, options);
this.parent = collection;
this.options = options;
}
clone(): ListIndexesCursor {
return new ListIndexesCursor(this.parent, {
...this.options,
...this.cursorOptions
});
}
/** @internal */
async _initialize(session: ClientSession | undefined): Promise<ExecutionResult> {
const operation = new ListIndexesOperation(this.parent, {
...this.cursorOptions,
...this.options,
session
});
const response = await executeOperation(this.parent.client, operation);
// TODO: NODE-2882
return { server: operation.server, session, response };
}
}