SaveJsonToSurreal
Drop workflow metadata into SurrealDB like it's a document store
- json
Images are half of a generation pipeline. The other half is the metadata - the prompt, the seed, the settings, the rating someone gives it later - and that's the half ComfyUI mostly ignores. SaveJsonToSurreal is one of a few nodes in the comfyui-tensorops pack that treat ComfyUI as a backend for a real app: image to S3, structured metadata into SurrealDB, strings and simple values into Redis. If you found it in a downloaded workflow, that's the shape of the pipeline you've inherited.
Fair warning about the pack while you're here: it's a single commit from October 2024 by GitHub user un-seen, and its one brush with the community was not flattering - ComfyUI Manager flagged it for node-name conflicts with Kijai's Florence2 pack, which Kijai read as copied code. It's MIT-licensed and quiet since. Useful if you're already building the SurrealDB piece; not something to install out of curiosity.
What it actually does
It writes a JSON payload into SurrealDB as a field on a record. The mechanics are worth knowing because they're fixed and a little unusual. It connects to SurrealDB using credentials from the pack's config.py (URL, namespace, user, password), and the database input you set on the node is the SurrealDB database it connects to - so different nodes in one workflow can write to different databases in the same namespace.
The record itself always lands in a table called processor, which is hardcoded in the source (SURREAL_TABLE = "processor") and not something you can change from the UI. The write is an upsert:
UPDATE processor:`id` CONTENT {key: json}
So the id input chooses the record, and the key input becomes a field name on it. Run it twice with the same id and the field updates in place. It's schema-less document-store behavior, which is exactly right for "attached data to a generation."
The inputs
- database - which SurrealDB database to connect to (the table is always
processor). - id - the record id to upsert.
- key - the field name your JSON is stored under.
- json - the JSON payload itself, wired in from any node that emits a JSON value.
No outputs - it's an output node and terminates the branch.
Installing and configuring
The repo ships no real README, so it's the standard path: ComfyUI Manager, search the pack title comfyui-tensorop, or:
cd ComfyUI/custom_nodes
git clone https://github.com/un-seen/comfyui-tensorops
then restart. The pack drags in a heavy requirements.txt (boto3, redis, surrealist, fal-client, replicate, scipy) even if you only want the SurrealDB nodes - that's just how this pack is built.
Then edit nodes/config.py - everything is hardcoded with empty-string defaults, no env vars, no .env:
SURREAL_URL = "http://localhost:8000"
SURREAL_NAMESPACE = "your-namespace"
SURREAL_USER = "root"
SURREAL_PASSWORD = "your-password"
Restart ComfyUI after editing. You also need a SurrealDB instance actually running and reachable - this node connects on every execution with a 10-second timeout, so a dead server means failed writes, not a graceful skip.
Gotchas
- The table is
processor, period. Want a different table? You're editingnodes/save_surreal.py. - The query is built by string interpolation. Your JSON is dropped raw into the
CONTENT {...}block. Valid JSON is balanced, so it works - but there's zero escaping layer, and malformed JSON from an upstream node breaks the statement. Send only what aJSON-typed node produces and you're fine. - The node's
databaseinput is the connection target, not the table. It's easy to read "database" as "bucket/folder" (the S3 node in this pack uses the same name for a path prefix) and end up writing to a database that doesn't exist. A nonexistent database can fail silently from the workflow's point of view - check the console log if nothing shows up in SurrealDB. - Timeout is 10 seconds. Long-surviving batches that call this per item can stack real latency.
If your value is a plain string rather than structured data, the pack's SaveTextToSurreal covers that case - but read its docs first, because that node has a quoting problem you'll want to dodge.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| database | STRING | — | |
| json | JSON | — | |
| id | STRING | — | |
| key | STRING | — |
Outputs (0)
No outputs