04 Metadata Flattened Paths
See every key a document actually has — ZMongo 04 Metadata Flattened Paths
- session
- json
- paths
- indexed
- count
04 Metadata Flattened Paths is the "what's actually inside this document?" node. You give it a session, collection, and document ID, and it flattens the nested structure into a list of dot-paths - every key you could address with 03 Get Value or 99 JSON Pick, laid out in one place. It's the map you need before you can navigate.
This is the node you reach for when dot-path hunting goes wrong. You've been typing metadata.seed into Get Value and getting nothing; the real path is image_data.metadata.seed or something with an unexpected nesting level. Instead of guessing, flatten the document and see the truth.
How it works
The node fetches the document and recursively walks dicts and lists, producing dot-path keys like metadata, metadata.seed, prompt.positive. A few behaviors worth knowing:
metadata_field_path(default empty) picks the subtree to flatten. Empty = whole document;metadata= just that subtree;image_data.metadata= nested metadata. So you can drill into one branch instead of dumping everything.contains_text- a filter: only return paths whose key or leaf contains this text. Handy when you know you're looking for something like "seed" but not where it lives.include_leaf_values- when on, the output includes leaf values (with a preview) instead of just key names.
One deliberate quirk: ZMongo's binary envelopes are treated as atomic. An image stored as image_data = {"__type__": "bytes", "data": "..."} flattens to a single image_data path - not image_data.data. That matches how the image nodes address fields, so you won't see phantom sub-paths that the read nodes can't actually resolve.
Outputs: paths (the list), indexed (preview text), count (how many paths), and json (full payload). A cache toggle (default false) and refresh_token round out the input set.
The inputs that matter
session,collection_name,document_id- the standard trio.metadata_field_path- which subtree to flatten.contains_text- the filter that turns a wall of paths into a short list.include_leaf_values- switch on when you want values alongside names.
Install
Standard:
cd ComfyUI/custom_nodes
git clone https://github.com/CentralFloridaAttorney/ComfyUI-ZMongo
cd ComfyUI-ZMongo
pip install -r requirements.txt
or ComfyUI Manager → "ComfyUI-ZMongo" → restart.
Troubleshooting
- Empty
paths- the document ID is stale, the collection name is wrong, orcontains_textfiltered everything out. Drop the filter first, then confirm the ID with03 List Docs. - A path you know exists isn't listed - check whether it's inside a
bytesenvelope. Binary fields flatten as one atomic path by design, so the sub-keys you'd expect from raw JSON won't appear. - Huge output on big documents - restrict with
metadata_field_pathandcontains_text. Flattening a document with embedded images or large lists can produce a long list fast. - Wrong subtree -
metadata_field_pathis relative to the document root.image_data.metadatareaches into the metadata of the image field; blank gets the whole document.
Flattened Paths is the discovery node that stops the "why is my dot-path not working" loop - run it once, copy the real path, move on.
Inputs (8)
| Name | Type | Default | Description |
|---|---|---|---|
| session | ZMONGO_API_SESSION | — | |
| collection_name | STRING | — | |
| document_id | STRING | — | |
| metadata_field_path | STRING | — | |
| contains_text | STRING | — | |
| include_leaf_values | BOOLEAN | false | — |
| cacheopt | BOOLEAN | false | — |
| refresh_tokenopt | STRING | — |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| json | STRING | — |
| paths | * | — |
| indexed | STRING | — |
| count | INT | — |