03 Update Doc
Change what's stored — ZMongo 03 Update Doc, and its two confusing modes
- session
- json
- refresh
03 Update Doc is how you modify what's already in your ZMongo database - update a stored prompt, bump a version, patch a parameter. It looks straightforward until you realize it has two very different ways of working, and picking the wrong one is the classic way to get "nothing changed" results and a confused afternoon.
Reading is only half of a parameter library. If ZMongo is your prompt hub, this node is how the hub stays current instead of ossifying into the first draft you saved.
The two modes (this is the whole game)
The node decides which mode you're in by whether you filled in update_json:
- Full update object mode. Put Mongo-style update operators in
update_json, e.g.{"$set": {"prompt.positive": "a new prompt"}}. Thefield_pathandvalue_jsoninputs are ignored. This is the flexible mode -$set,$inc,$push, whatever your backend supports. - Single field/value mode. Leave
update_jsonempty and instead setfield_path(dot-path likeprompt.positive) plusvalue_json. The node writes that one value into that one path. This is the mode you'll use 90% of the time when you just want to change one stored string.
parse_value_json (default true) matters in mode 2: when true, your value_json text is parsed as JSON, so "42" stores a number and {"a":1} stores an object. When false, the text is stored as a literal string. If your "value" is prose that happens to look like JSON, flip this off or it'll be silently coerced.
upsert (default false) is the "create if missing" switch: true means "update the doc if found, insert it if not."
How it works
The node builds a query from query_json and document_id, picks the mode as above, and calls session.update_doc(). Outputs are just json (the response) and refresh - a token that changes whenever the write happens, so downstream nodes that cached the old value know to re-read. There's no success boolean here; read json for the outcome.
The inputs and outputs that matter
session,collection_name- as always.query_json- the filter identifying the doc(s).{}+ adocument_idis the safest combo.document_id- direct ID targeting.update_jsonvsfield_path+value_json- pick your mode.parse_value_json,upsert- the two switches that cause most "why did it store that weird" surprises.
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
- "Nothing changed" even though you set
field_pathandvalue_json- checkupdate_json: if it isn't empty, the node ignores your field/value mode entirely. Clear it. - A prompt saved as
42ortruewhen you wanted "42" -parse_value_jsonis on. That's by design; turn it off to store literal text. - No matching document - the query matched zero rows. If you don't want a silent no-op, set
upsert: trueso a miss creates the record. - Malformed
query_json- remember it must be a JSON object.{"project_name": "default"}good, bareproject_name: defaultbad.
Update Doc is the write-side counterpart to 03 Get Value/03 Save Value, and once you're comfortable with its two modes it stops being scary - it's just "find the row, change the thing."
Inputs (9)
| Name | Type | Default | Description |
|---|---|---|---|
| session | ZMONGO_API_SESSION | — | |
| collection_name | STRING | — | |
| query_json | STRING | {} | — |
| document_id | STRING | — | |
| update_json | STRING | — | |
| field_path | STRING | — | |
| value_json | STRING | — | |
| parse_value_json | BOOLEAN | true | — |
| upsert | BOOLEAN | false | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| json | STRING | — |
| refresh | STRING | — |