Nodes/ComfyUI-ZMongo/06 Save Document Value
ComfyUI Node

06 Save Document Value

Write to any field in a document, dot-path included

By CentralFloridaAttorney·Created 5 months ago·Updated 2 months ago· 1
06 Save Document Value
  • session
  • document_id_link
  • field_path_link
  • json
  • document_id
  • success
  • refresh
  • document_ids
  • selectable_items
  • indexed_items
  • item_count
document_id
field_pathmetadata.note
value
parse_jsontrue
normalize_for_storagefalse
document_prefix/documents
refresh_token

Save Text writes to one hardcoded field; this node writes to any field you name. "06 Save Document Value" takes a field_path in dot notation - metadata.note, prompt.positive, whatever - and writes a value there, creating intermediate dicts along the way if they don't exist. If you're building a parameter library or logging structured state from your workflows, this is the node that makes it possible without writing a single line of Python.

How it works

It POSTs to /api/save-value/{document_id} with {field_path, value, parse_json, normalize_for_storage}. The two toggles matter:

  • parse_json (default true) - if your value string is valid JSON, it's parsed and stored as a real object/array/number instead of a string. Turn it off if you genuinely want the literal text {"a": 1} stored as a string.
  • normalize_for_storage (default false) - asks the backend to normalize/normalize the stored representation. Leave it off until you know you need it; it's for the hosted backend's conventions.

value is a multiline string input, which is why parse_json exists - everything comes in as text and you decide how it's interpreted. document_id (or the typed document_id_link) says which document, field_path (or field_path_link) says where.

Outputs: json, document_id, success (did the write commit), refresh, and the document_ids tail. Notably, this node does not raise on failure - a failed write shows up in json with success: false but doesn't kill your graph, because it's meant to be used in demo/selector workflows where you might point at a bad field.

Install

cd ComfyUI/custom_nodes
git clone https://github.com/CentralFloridaAttorney/ComfyUI-ZMongo

Restart, or install via ComfyUI Manager ("ComfyUI-ZMongo").

Where people get burned

The immutable-fields guard is the big one. ZMongo refuses to let you write to identity/ownership fields - _id in particular. Try to save to _id and you'll get a clean, visible failure payload telling you to pick a writable path. That's a feature: MongoDB would reject the write anyway, and this way you find out before anything breaks.

Second, field_path is a dot path, not a slash path and not a JSON path - metadata.note, not metadata/note. And unless parse_json is on, everything lands as a string; a numeric-looking value that comes back as a string from "06 Get Document Value" is usually you forgetting that this default was on or off for the wrong reason.

Pair it with "06 Document Field Paths" to learn the paths before you write to them. That read-then-write loop - Field Paths → Save Value → Get Value to verify - is the core rhythm of using ZMongo as a state store, and it's surprisingly pleasant once it clicks.

CategoryZMongo/03 Documents

Inputs (10)

NameTypeDefaultDescription
sessionZMONGO_API_SESSION
document_idSTRING
field_pathSTRINGmetadata.note
valueSTRING
parse_jsonBOOLEANtrue
normalize_for_storageBOOLEANfalse
document_prefixSTRING/documents
document_id_linkopt*
field_path_linkopt*
refresh_tokenoptSTRING

Outputs (8)

NameTypeDescription
jsonSTRING
document_idSTRING
successBOOLEAN
refreshSTRING
document_ids*
selectable_items*
indexed_itemsSTRING
item_countINT