( parent: OperationParent | undefined, options?: T )
| 511 | * @internal |
| 512 | */ |
| 513 | export function resolveOptions<T extends CommandOperationOptions>( |
| 514 | parent: OperationParent | undefined, |
| 515 | options?: T |
| 516 | ): T { |
| 517 | const result: T = Object.assign({}, options, resolveBSONOptions(options, parent)); |
| 518 | |
| 519 | const timeoutMS = options?.timeoutMS ?? parent?.timeoutMS; |
| 520 | class="cm">// Users cannot pass a readConcern/writeConcern to operations in a transaction |
| 521 | const session = options?.session; |
| 522 | |
| 523 | if (!session?.inTransaction()) { |
| 524 | const readConcern = ReadConcern.fromOptions(options) ?? parent?.readConcern; |
| 525 | if (readConcern) { |
| 526 | result.readConcern = readConcern; |
| 527 | } |
| 528 | |
| 529 | let writeConcern = WriteConcern.fromOptions(options) ?? parent?.writeConcern; |
| 530 | if (writeConcern) { |
| 531 | if (timeoutMS != null) { |
| 532 | writeConcern = WriteConcern.fromOptions({ |
| 533 | writeConcern: { |
| 534 | ...writeConcern, |
| 535 | wtimeout: undefined, |
| 536 | wtimeoutMS: undefined |
| 537 | } |
| 538 | }); |
| 539 | } |
| 540 | result.writeConcern = writeConcern; |
| 541 | } |
| 542 | } |
| 543 | |
| 544 | result.timeoutMS = timeoutMS; |
| 545 | |
| 546 | const readPreference = ReadPreference.fromOptions(options) ?? parent?.readPreference; |
| 547 | if (readPreference) { |
| 548 | result.readPreference = readPreference; |
| 549 | } |
| 550 | |
| 551 | const isConvenientTransaction = session?.explicit && session?.timeoutContext != null; |
| 552 | if (isConvenientTransaction && options?.timeoutMS != null) { |
| 553 | throw new MongoInvalidArgumentError( |
| 554 | class="st">'An operation cannot be given a timeoutMS setting when inside a withTransaction call that has a timeoutMS setting' |
| 555 | ); |
| 556 | } |
| 557 | |
| 558 | return result; |
| 559 | } |
| 560 | |
| 561 | export function isSuperset(set: Set<any> | any[], subset: Set<any> | any[]): boolean { |
| 562 | set = Array.isArray(set) ? new Set(set) : set; |
no test coverage detected