1
1
import { indexInformation , IndexInformationOptions } from './common_functions' ;
2
2
import { OperationBase , Aspect , defineAspects } from './operation' ;
3
3
import { MongoError } from '../error' ;
4
- import { maxWireVersion , parseIndexOptions , MongoDBNamespace , Callback } from '../utils' ;
4
+ import {
5
+ maxWireVersion ,
6
+ parseIndexOptions ,
7
+ MongoDBNamespace ,
8
+ Callback ,
9
+ deepFreeze
10
+ } from '../utils' ;
5
11
import { CommandOperation , CommandOperationOptions , OperationParent } from './command' ;
6
12
import { ReadPreference } from '../read_preference' ;
7
13
import type { Server } from '../sdam/server' ;
@@ -141,6 +147,14 @@ export class CreateIndexesOperation extends CommandOperation<CreateIndexesOption
141
147
onlyReturnNameOfCreatedIndex ?: boolean ;
142
148
indexes : IndexDescription [ ] ;
143
149
150
+ get builtOptions ( ) : Readonly < CreateIndexesOptions > {
151
+ return deepFreeze ( {
152
+ ...super . builtOptions ,
153
+ // collation is set on each index, it should not be defined at the root
154
+ collation : undefined
155
+ } ) ;
156
+ }
157
+
144
158
constructor (
145
159
parent : OperationParent ,
146
160
collectionName : string ,
@@ -157,7 +171,7 @@ export class CreateIndexesOperation extends CommandOperation<CreateIndexesOption
157
171
}
158
172
159
173
execute ( server : Server , callback : Callback < Document > ) : void {
160
- const options = this . options ;
174
+ const options = this . builtOptions ;
161
175
const indexes = this . indexes ;
162
176
163
177
const serverWireVersion = maxWireVersion ( server ) ;
@@ -199,9 +213,6 @@ export class CreateIndexesOperation extends CommandOperation<CreateIndexesOption
199
213
cmd . commitQuorum = options . commitQuorum ;
200
214
}
201
215
202
- // collation is set on each index, it should not be defined at the root
203
- this . options . collation = undefined ;
204
-
205
216
super . executeCommand ( server , cmd , ( err , result ) => {
206
217
if ( err ) {
207
218
callback ( err ) ;
0 commit comments