03 Save Value
Store one value by dot-path — ZMongo 03 Save Value
- session
- json
- refresh
- success
03 Save Value is the write counterpart to 03 Get Value - the node that takes a value from your graph and stores it at a dot-path inside a document. This is the "save my winning prompt back to the database" node, and it's the reason ZMongo works as a prompt hub rather than just a place to look at JSON.
The write pattern is the mirror of the read pattern: pick a collection and document, name a dot-path like prompt.positive, give it a value, and the node writes it into the stored record. You can save over existing fields, create new ones, and - with upsert_if_missing - even create the document on the fly if it doesn't exist yet.
How it works
The node locates the target document via query_json and/or document_id, then writes your value at field_path. The behavior is controlled by a few switches that are easy to misread:
parse_value_json(defaulttrue) - when on, yourvalue_jsontext is parsed as JSON first."42"becomes a number,{"a":1}becomes an object,"hello"stays a string. When off, the text is stored literally.parse_json_strings(defaulttrue) - controls whether strings that themselves look like JSON get recursively parsed. Keep it on unless you're storing text that legitimately resembles JSON.normalize_for_storage(defaultfalse) - cleans/normalizes the value for storage. Off by default; flip it on if you want consistency guarantees and understand what the pack normalizes.upsert_if_missing(defaultfalse) -truemeans "insert the document if the query finds nothing." Without it, a miss is a silent no-op.
Outputs: json (the response), refresh (a token that changes when a write happens - downstream cache-aware nodes use it to know the data changed), and success (boolean, the one write node in the docs family that exposes it directly).
The inputs and outputs that matter
session,collection_name,field_path- required. Notecollection_nameandfield_pathare hard-required here (the node errors out ifcollection_nameis empty - a stricter stance than the read nodes).value_json- the value, or JSON representing it, depending onparse_value_json.upsert_if_missing- the "create if absent" switch. Beginners usually want this on once they trust their query.
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. No model downloads.
Troubleshooting
- A string that "shouldn't" have changed got converted -
parse_value_jsonis on and your text looked like JSON. Flip it off to store raw text. success: falsewith "field_path is required" - you can't save with an empty path. Name the field explicitly; saving "nowhere" is rejected by design.- Nothing saved and no error -
upsert_if_missingis false and the query matched nothing. Either tighten the query or enable upsert. - Value landed in the wrong document -
query_jsonmatched more than you intended, ordocument_idwas stale. Re-list with03 List Docsto confirm the ID.
Save Value plus Get Value are the pair that makes the whole "database as a parameter library" pitch real - once you're saving and loading prompts by path, hardcoded text starts feeling ancient.
Inputs (10)
| Name | Type | Default | Description |
|---|---|---|---|
| session | ZMONGO_API_SESSION | — | |
| collection_name | STRING | — | |
| query_json | STRING | {} | — |
| document_id | STRING | — | |
| field_path | STRING | — | |
| value_json | STRING | — | |
| parse_value_json | BOOLEAN | true | — |
| upsert_if_missing | BOOLEAN | false | — |
| parse_json_strings | BOOLEAN | true | — |
| normalize_for_storage | BOOLEAN | false | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| json | STRING | — |
| refresh | STRING | — |
| success | BOOLEAN | — |