MCPcopy
hub / github.com/mongodb/node-mongodb-native / hasAtomicOperators

Function hasAtomicOperators

src/utils.ts:458–490  ·  src/utils.ts::hasAtomicOperators
(
  doc: Document | Document[],
  options?: CommandOperationOptions
)

Source from the content-addressed store, hash-verified

456
457/** @internal */
458export 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
492export function resolveTimeoutOptions<T extends Partial<TimeoutContextOptions>>(
493 client: MongoClient,

Callers 11

updateOneMethod · 0.90
replaceOneMethod · 0.90
rawFunction · 0.90
constructorMethod · 0.90
constructorMethod · 0.90
constructorMethod · 0.90
constructorMethod · 0.90
constructorMethod · 0.90
validateUpdateFunction · 0.90
buildReplaceOneOperationFunction · 0.90
utils.test.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected