Nodes/ComfyUI-ZMongo/03 Update Doc
ComfyUI Node

03 Update Doc

Change what's stored — ZMongo 03 Update Doc, and its two confusing modes

By CentralFloridaAttorney·Created 5 months ago·Updated 2 months ago· 1
03 Update Doc
  • session
  • json
  • refresh
collection_name
query_json{}
document_id
update_json
field_path
value_json
parse_value_jsontrue
upsertfalse

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:

  1. Full update object mode. Put Mongo-style update operators in update_json, e.g. {"$set": {"prompt.positive": "a new prompt"}}. The field_path and value_json inputs are ignored. This is the flexible mode - $set, $inc, $push, whatever your backend supports.
  2. Single field/value mode. Leave update_json empty and instead set field_path (dot-path like prompt.positive) plus value_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). {} + a document_id is the safest combo.
  • document_id - direct ID targeting.
  • update_json vs field_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_path and value_json - check update_json: if it isn't empty, the node ignores your field/value mode entirely. Clear it.
  • A prompt saved as 42 or true when you wanted "42" - parse_value_json is 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: true so a miss creates the record.
  • Malformed query_json - remember it must be a JSON object. {"project_name": "default"} good, bare project_name: default bad.

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."

CategoryZMongo/02 Docs

Inputs (9)

NameTypeDefaultDescription
sessionZMONGO_API_SESSION
collection_nameSTRING
query_jsonSTRING{}
document_idSTRING
update_jsonSTRING
field_pathSTRING
value_jsonSTRING
parse_value_jsonBOOLEANtrue
upsertBOOLEANfalse

Outputs (2)

NameTypeDescription
jsonSTRING
refreshSTRING