| 535 | } |
| 536 | |
| 537 | private buildQueryOptions( |
| 538 | options: Pick< |
| 539 | FindOptions<any, any, any, any>, |
| 540 | 'collation' | 'indexHint' | 'using' | 'maxTimeMS' | 'allowDiskUse' | 'signal' |
| 541 | >, |
| 542 | ): MongoQueryOptions { |
| 543 | if (options.collation != null && typeof options.collation === 'string') { |
| 544 | throw new Error( |
| 545 | "Collation option for MongoDB must be a CollationOptions object (e.g. { locale: 'en' }). Use a string only with SQL drivers.", |
| 546 | ); |
| 547 | } |
| 548 | |
| 549 | const ret: MongoQueryOptions = {}; |
| 550 | |
| 551 | if (options.collation) { |
| 552 | ret.collation = options.collation; |
| 553 | } |
| 554 | |
| 555 | if (options.indexHint != null) { |
| 556 | ret.indexHint = options.indexHint; |
| 557 | } else if (options.using != null) { |
| 558 | const names = Utils.asArray(options.using); |
| 559 | |
| 560 | if (names.length > 1) { |
| 561 | throw new Error( |
| 562 | 'MongoDB only supports a single index hint per query. Provide one index name instead of an array.', |
| 563 | ); |
| 564 | } |
| 565 | |
| 566 | ret.indexHint = names[0]; |
| 567 | } |
| 568 | |
| 569 | if (options.maxTimeMS != null) { |
| 570 | ret.maxTimeMS = options.maxTimeMS; |
| 571 | } |
| 572 | |
| 573 | if (options.allowDiskUse != null) { |
| 574 | ret.allowDiskUse = options.allowDiskUse; |
| 575 | } |
| 576 | |
| 577 | if (options.signal) { |
| 578 | ret.signal = options.signal; |
| 579 | } |
| 580 | |
| 581 | return ret; |
| 582 | } |
| 583 | |
| 584 | /** @internal */ |
| 585 | renameFields<T extends object>( |