( doc: Document | Document[], options?: CommandOperationOptions )
| 456 | |
| 457 | /** @internal */ |
| 458 | export function hasAtomicOperators( |
| 459 | doc: Document | Document[], |
| 460 | options?: CommandOperationOptions |
| 461 | ): boolean { |
| 462 | if (Array.isArray(doc)) { |
| 463 | for (const document of doc) { |
| 464 | if (hasAtomicOperators(document)) { |
| 465 | return true; |
| 466 | } |
| 467 | } |
| 468 | return false; |
| 469 | } |
| 470 | |
| 471 | const keys = Object.keys(doc); |
| 472 | class="cm">// In this case we need to throw if all the atomic operators are undefined. |
| 473 | if (options?.ignoreUndefined) { |
| 474 | let allUndefined = true; |
| 475 | for (const key of keys) { |
| 476 | class="cm">// eslint-disable-next-line no-restricted-syntax |
| 477 | if (doc[key] !== undefined) { |
| 478 | allUndefined = false; |
| 479 | break; |
| 480 | } |
| 481 | } |
| 482 | if (allUndefined) { |
| 483 | throw new MongoInvalidArgumentError( |
| 484 | class="st">'Update operations require that all atomic operators have defined values, but none were provided.' |
| 485 | ); |
| 486 | } |
| 487 | } |
| 488 | |
| 489 | return keys.length > 0 && keys[0][0] === class="st">'$'; |
| 490 | } |
| 491 | |
| 492 | export function resolveTimeoutOptions<T extends Partial<TimeoutContextOptions>>( |
| 493 | client: MongoClient, |
no outgoing calls
no test coverage detected