Nodes/ComfyUI-ZMongo/03 Save Value
ComfyUI Node

03 Save Value

Store one value by dot-path — ZMongo 03 Save Value

By CentralFloridaAttorney·Created 5 months ago·Updated 2 months ago· 1
03 Save Value
  • session
  • json
  • refresh
  • success
collection_name
query_json{}
document_id
field_path
value_json
parse_value_jsontrue
upsert_if_missingfalse
parse_json_stringstrue
normalize_for_storagefalse

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 (default true) - when on, your value_json text 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 (default true) - 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 (default false) - 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 (default false) - true means "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. Note collection_name and field_path are hard-required here (the node errors out if collection_name is empty - a stricter stance than the read nodes).
  • value_json - the value, or JSON representing it, depending on parse_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_json is on and your text looked like JSON. Flip it off to store raw text.
  • success: false with "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_missing is false and the query matched nothing. Either tighten the query or enable upsert.
  • Value landed in the wrong document - query_json matched more than you intended, or document_id was stale. Re-list with 03 List Docs to 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.

CategoryZMongo/02 Docs

Inputs (10)

NameTypeDefaultDescription
sessionZMONGO_API_SESSION
collection_nameSTRING
query_jsonSTRING{}
document_idSTRING
field_pathSTRING
value_jsonSTRING
parse_value_jsonBOOLEANtrue
upsert_if_missingBOOLEANfalse
parse_json_stringsBOOLEANtrue
normalize_for_storageBOOLEANfalse

Outputs (3)

NameTypeDescription
jsonSTRING
refreshSTRING
successBOOLEAN