@@ -3,8 +3,7 @@ import type { Document } from 'bson';
3
3
import type { Collection } from '../../collection' ;
4
4
import type { Server } from '../../sdam/server' ;
5
5
import type { ClientSession } from '../../sessions' ;
6
- import type { Callback } from '../../utils' ;
7
- import { AbstractCallbackOperation } from '../operation' ;
6
+ import { AbstractOperation } from '../operation' ;
8
7
9
8
/**
10
9
* @public
@@ -18,37 +17,24 @@ export interface SearchIndexDescription {
18
17
}
19
18
20
19
/** @internal */
21
- export class CreateSearchIndexesOperation extends AbstractCallbackOperation < string [ ] > {
20
+ export class CreateSearchIndexesOperation extends AbstractOperation < string [ ] > {
22
21
constructor (
23
22
private readonly collection : Collection ,
24
23
private readonly descriptions : ReadonlyArray < SearchIndexDescription >
25
24
) {
26
25
super ( ) ;
27
26
}
28
27
29
- executeCallback (
30
- server : Server ,
31
- session : ClientSession | undefined ,
32
- callback : Callback < string [ ] >
33
- ) : void {
28
+ override async execute ( server : Server , session : ClientSession | undefined ) : Promise < string [ ] > {
34
29
const namespace = this . collection . fullNamespace ;
35
30
const command = {
36
31
createSearchIndexes : namespace . collection ,
37
32
indexes : this . descriptions
38
33
} ;
39
34
40
- server . command ( namespace , command , { session } , ( err , res ) => {
41
- if ( err || ! res ) {
42
- callback ( err ) ;
43
- return ;
44
- }
35
+ const res = await server . commandAsync ( namespace , command , { session } ) ;
45
36
46
- const indexesCreated : Array < { name : string } > = res ?. indexesCreated ?? [ ] ;
47
-
48
- callback (
49
- undefined ,
50
- indexesCreated . map ( ( { name } ) => name )
51
- ) ;
52
- } ) ;
37
+ const indexesCreated : Array < { name : string } > = res ?. indexesCreated ?? [ ] ;
38
+ return indexesCreated . map ( ( { name } ) => name ) ;
53
39
}
54
40
}
0 commit comments