{"record":{"id":"85da75b07b132458","repo":"meteor/meteor","slug":"no-expressions-in-all","errorCode":null,"errorMessage":"no $ expressions in $all","messagePattern":"no \\$ expressions in \\$all","errorType":"exception","errorClass":"MiniMongoQueryError","httpStatus":null,"severity":"error","filePath":"packages/minimongo/common.js","lineNumber":386,"sourceCode":"      throw new MiniMongoQueryError('$maxDistance needs a $near');\n    }\n\n    return everythingMatcher;\n  },\n  $all(operand, valueSelector, matcher) {\n    if (!Array.isArray(operand)) {\n      throw new MiniMongoQueryError('$all requires array');\n    }\n\n    // Not sure why, but this seems to be what MongoDB does.\n    if (operand.length === 0) {\n      return nothingMatcher;\n    }\n\n    const branchedMatchers = operand.map(criterion => {\n      // XXX handle $all/$elemMatch combination\n      if (isOperatorObject(criterion)) {\n        throw new MiniMongoQueryError('no $ expressions in $all');\n      }\n\n      // This is always a regexp or equality selector.\n      return compileValueSelector(criterion, matcher);\n    });\n\n    // andBranchedMatchers does NOT require all selectors to return true on the\n    // SAME branch.\n    return andBranchedMatchers(branchedMatchers);\n  },\n  $near(operand, valueSelector, matcher, isRoot) {\n    if (!isRoot) {\n      throw new MiniMongoQueryError('$near can\\'t be inside another $ operator');\n    }\n\n    matcher._hasGeoQuery = true;\n\n    // There are two kinds of geodata in MongoDB: legacy coordinate pairs and","sourceCodeStart":368,"sourceCodeEnd":404,"githubUrl":"https://github.com/meteor/meteor/blob/5076d2f818d3cac01d0cf8312fa5b2332076a4fb/packages/minimongo/common.js#L368-L404","documentation":"Thrown by the $all operator when any criterion inside the operand array is itself an operator object. The comment notes that $all/$elemMatch combination is not handled (XXX); $all only accepts equality values or RegExp, so $gt/$ne/etc. inside $all is rejected via isOperatorObject.","triggerScenarios":"Using {field: {$all: [{$gt: 5}]}} or {field: {$all: [{$elemMatch: {...}}]}} in a minimongo query. Each element is checked with isOperatorObject.","commonSituations":"Trying to require that an array contains an element matching a sub-query; copying a MongoDB example that uses $elemMatch inside $all (minimongo does not support that combination); merging selectors that inject operators.","solutions":["Use plain equality values in $all: {field: {$all: ['a', 'b']}}.","For operator-based element matching across an array, use $elemMatch at the field level instead of nesting in $all.","For RegExp membership, $all does accept RegExp instances: {field: {$all: [/^a/]}}."],"exampleFix":"// before\ncollection.find({ tags: { $all: [{$gt: 'a'}] } });\n// after\ncollection.find({ tags: { $all: ['b', 'c'] } });","handlingStrategy":"validation","validationCode":"function buildAllSelector(values) {\n  const bad = values.filter(v => v !== null && typeof v === 'object' && !(v instanceof RegExp) && Object.keys(v).some(k => k.startsWith('$')));\n  if (bad.length) throw new Error('$all does not support nested operators');\n  return { $all: values };\n}","typeGuard":"function isPlainAllElement(el) {\n  return el instanceof RegExp || el === null || typeof el !== 'object' || Object.keys(el).every(k => !k.startsWith('$'));\n}","tryCatchPattern":null,"preventionTips":["Use only equality values or RegExp in $all.","Use $elemMatch at field level for operator-based element matching.","Validate dynamically-built $all arrays for $ keys."],"tags":["minimongo","query","operator","all","nested-operator","validation"],"backgroundTag":null,"analyzedSha":"5076d2f818d3cac01d0cf8312fa5b2332076a4fb","analyzedAt":"2026-08-13T03:27:40.142Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}