(
parent: OperationParent,
collectionName: string,
indexes: IndexDescription[],
options?: CreateIndexesOptions
)
| 249 | indexes: ReadonlyArray<ResolvedIndexDescription>; |
| 250 | |
| 251 | private constructor( |
| 252 | parent: OperationParent, |
| 253 | collectionName: string, |
| 254 | indexes: IndexDescription[], |
| 255 | options?: CreateIndexesOptions |
| 256 | ) { |
| 257 | super(parent, options); |
| 258 | |
| 259 | this.options = options ?? {}; |
| 260 | // collation is set on each index, it should not be defined at the root |
| 261 | this.options.collation = undefined; |
| 262 | this.collectionName = collectionName; |
| 263 | this.indexes = indexes.map((userIndex: IndexDescription): ResolvedIndexDescription => { |
| 264 | // Ensure the key is a Map to preserve index key ordering |
| 265 | const key = |
| 266 | userIndex.key instanceof Map ? userIndex.key : new Map(Object.entries(userIndex.key)); |
| 267 | const name = userIndex.name ?? Array.from(key).flat().join('_'); |
| 268 | const validIndexOptions = resolveIndexDescription(userIndex); |
| 269 | return { |
| 270 | ...validIndexOptions, |
| 271 | name, |
| 272 | key |
| 273 | }; |
| 274 | }); |
| 275 | this.ns = parent.s.namespace; |
| 276 | } |
| 277 | |
| 278 | static fromIndexDescriptionArray( |
| 279 | parent: OperationParent, |
nothing calls this directly
no test coverage detected