pubkey/rxdb · error · RxError
DOC1
DOC1
Error message
RxDB Error-Code: DOC1. Hint: Error messages are not included in RxDB core to reduce build size. To show the full error messages and to ensure that you do not make any mistakes when using RxDB, use the dev-mode plugin when you are in development mode: https://rxdb.info/dev-mode.html?console=error
What it means
DOC1 is thrown by RxDocument.get$(path) (and .get()) when the observed path contains '.item.'. RxDB does not support observing array items via this placeholder syntax; array fields must be observed as a whole and iterated in code. This check only runs when the dev-mode plugin is enabled.
Source
Thrown at src/rx-document.ts:139
);
},
get $$(): any {
const _this: RxDocument = this as any;
const reactivity = _this.collection.database.getReactivityFactory();
return reactivity.fromObservable(
_this.$,
_this.getLatest()._data,
_this.collection.database
);
},
/**
* returns observable of the value of the given path
*/
get$(this: RxDocument, path: string): Observable<any> {
if (overwritable.isDevMode()) {
if (path.includes('.item.')) {
throw newRxError('DOC1', {
path
});
}
if (path === this.primaryPath) {
throw newRxError('DOC2');
}
// final fields cannot be modified and so also not observed
if (this.collection.schema.finalFields.includes(path)) {
throw newRxError('DOC3', {
path
});
}
const schemaObj = getSchemaByObjectPath(
this.collection.schema.jsonSchema,
pathView on GitHub (pinned to af6fb65f94)
Solutions
- Observe the whole array field instead: doc.get$('tags') then map/filter in the subscription.
- For a specific element, compute it from the array value: doc.get$('tags').pipe(map(arr => arr[0])).
- Remove '.item.' from any dynamically generated paths.
Example fix
// before
doc.get$('tags.item.0').subscribe(v => ...);
// after
import { map } from 'rxjs';
doc.get$('tags').pipe(map(tags => tags[0])).subscribe(v => ...); Defensive patterns
Strategy: validation
Validate before calling
function assertObservablePath(path, doc) {
if (typeof path === 'string' && path.includes('.item.')) {
throw new Error('Cannot observe array item path: ' + path);
}
} Type guard
function isObservablePath(path) {
return typeof path === 'string' && !path.includes('.item.');
} Try / catch
try {
obs = doc.get$(path);
} catch (err) {
if (String(err?.code) === 'DOC1') {
// fall back to observing the parent array field
obs = doc.get$(path.split('.item.')[0]);
} else {
throw err;
}
} Prevention
- Never build paths containing '.item.'; observe the array field and map in RxJS.
- Sanitize dynamically generated field paths before calling get$.
- Run with the dev-mode plugin in development so these mistakes surface immediately.
- Check the schema: arrays are observed as a whole, not per item.
When it happens
Trigger: Calling doc.get$('tags.item.0') or similar paths containing '.item.' while the dev-mode plugin is active; also commonly via doc.getField().$ or reactive property access built from a path string containing '.item.'.
Common situations: Porting code from RxDB versions or other databases that supported per-item array observation; dynamically constructing observable paths from UI config that includes '.item.'; misunderstanding docs on nested array observation.
Related errors
AI-assisted analysis of pubkey/rxdb@af6fb65f94 (2026-08-31).
Data as JSON: /api/errors/b3abeb087f576055.
Report an issue: GitHub.