{"record":{"id":"ca72dfd89e51713f","repo":"pubkey/rxdb","slug":"qu9","errorCode":"QU9","errorMessage":"\n        RxDB Error-Code: ${message}.\n        Hint: Error messages are not included in RxDB core to reduce build size.\n        To show the full error messages and to ensure that you do not make any mistakes when using RxDB,\n        use the dev-mode plugin when you are in development mode: https://rxdb.info/dev-mode.html?console=error\n        \nFind out more about this error here: https://rxdb.info/errors.html?console=errors#${message} \nStill stuck? Ask in the RxDB Discord: https://rxdb.info/chat \n","messagePattern":"\n        RxDB Error-Code: \\$\\{message\\}\\.\n        Hint: Error messages are not included in RxDB core to reduce build size\\.\n        To show the full error messages and to ensure that you do not make any mistakes when using RxDB,\n        use the dev-mode plugin when you are in development mode: https://rxdb\\.info/dev-mode\\.html\\?console=error\n        \nFind out more about this error here: https://rxdb\\.info/errors\\.html\\?console=errors#\\$\\{message\\} \nStill stuck\\? Ask in the RxDB Discord: https://rxdb\\.info/chat \n","errorType":"error_code","errorClass":"RxError","httpStatus":null,"severity":"error","filePath":"src/rx-query.ts","lineNumber":373,"sourceCode":"         */\n        if (this.collection._changeEventBuffer.getCounter() !== counterBefore) {\n            await promiseWait(20);\n            return this._execOverDatabase(rerunCount + 1);\n        }\n\n        return result;\n    }\n\n    /**\n     * Execute the query\n     * To have an easier implementations,\n     * just subscribe and use the first result\n     */\n    public exec(throwIfMissing: true): Promise<RxDocument<RxDocType, OrmMethods, Reactivity>>;\n    public exec(): Promise<RxQueryResult>;\n    public async exec(throwIfMissing?: boolean): Promise<any> {\n        if (throwIfMissing && this.op !== 'findOne') {\n            throw newRxError('QU9', {\n                collection: this.collection.name,\n                query: this.mangoQuery,\n                op: this.op\n            });\n        }\n\n        /**\n         * run _ensureEqual() here,\n         * this will make sure that errors in the query which throw inside of the RxStorage,\n         * will be thrown at this execution context and not in the background.\n         */\n        await _ensureEqual(this as any);\n        const useResult = ensureNotFalsy(this._result);\n        return useResult.getValue(throwIfMissing);\n    }\n\n\n","sourceCodeStart":355,"sourceCodeEnd":391,"githubUrl":"https://github.com/pubkey/rxdb/blob/af6fb65f94cd70558d74c23799eda11ff1c15224/src/rx-query.ts#L355-L391","documentation":"RxQuery.exec(throwIfMissing) with a truthy argument is only valid on findOne() queries. When the query's op is 'find' (or any op other than 'findOne'), RxDB throws QU9 because there is no meaningful 'missing document' semantics for a multi-result query. RxDB core throws error codes without full messages to keep the production build small; the dev-mode plugin fills in the text.","triggerScenarios":"Calling myQuery.exec(true) on a query created with .find() instead of .findOne(); copying findOne-style code onto a find() query; a helper that accepts a query and always passes throwIfMissing=true.","commonSituations":"Refactoring a findOne query to find to get all results while keeping exec(true); wrapping generic query-execution utilities; TypeScript types usually catch this, but plain JS or any-typed code paths do not.","solutions":["Call exec() without arguments (or with false) on find() queries and check the returned array yourself.","If you need the missing-document error, switch the query to findOne() before calling exec(true).","Add the dev-mode plugin in development to see the full QU9 message."],"exampleFix":"// before\nconst docs = await collection.find(selector).exec(true);\n// after\nconst docs = await collection.find(selector).exec();\n// or, if you really want throw-if-missing:\nconst doc = await collection.findOne(selector).exec(true);","handlingStrategy":"validation","validationCode":"if (query.op !== 'findOne') {\n  const docs = await query.exec(); // never pass true to a find() query\n} else {\n  const doc = await query.exec(true);\n}","typeGuard":"function isFindOneQuery(q: RxQuery<any, any>): boolean {\n  return (q as any).op === 'findOne';\n}","tryCatchPattern":"try {\n  const doc = await query.exec(true);\n} catch (err) {\n  if (err.code === 'QU9') {\n    const doc = await query.exec();\n  } else { throw err; }\n}","preventionTips":["Only pass exec(true) on findOne() queries; TypeScript overloads enforce this, avoid any-typed query variables.","Prefer exec() + explicit array/null checks for clarity.","Run with the dev-mode plugin in development so error codes show full messages."],"tags":["rxquery","find","api-misuse"],"backgroundTag":"invalid-argument-combination","analyzedSha":"af6fb65f94cd70558d74c23799eda11ff1c15224","analyzedAt":"2026-08-31T23:32:37.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}