Nodes/ComfyUI-ZMongo/03 Count Docs
ComfyUI Node

03 Count Docs

Knowing how much is in your store before you build around it

By CentralFloridaAttorney·Created 5 months ago·Updated 2 months ago· 1
03 Count Docs
  • session
  • json
  • count
collection_name
query_json{}
document_id
cachefalse
refresh_token

03 Count Docs answers the most boring and most useful question in any data-backed workflow: how many documents are actually in there? It's a read-only node that returns a count for a collection, optionally filtered by a query.

Why bother? Because ZMongo's pitch is treating your store as a parameter library and asset hub, and every "loop over all my prompts" or "did the batch land?" workflow starts with a count. It's also a great cheap sanity check - fire it after a batch save and confirm the number grew, before you build a whole downstream pipeline on an assumption.

How it works

Required inputs:

  • session - from the API Key Session node.
  • collection_name - the collection to count.
  • query_json - a Mongo-style filter, defaults to {} (counts everything).
  • document_id - count a single document by id if you like (the backend handles a targeted count).
  • cache - boolean, default false. Turn it on if the count is expensive and you're polling repeatedly; just remember a cached count can be stale.

Outputs are lean:

  • json - the full backend payload (so you can see the raw response if the count looks wrong).
  • count - the integer. The node digs through the response for a token/total/count key; if the backend shape changes, count falls back to 0 rather than crashing.

Tips

  • An optional refresh_token input exists - wire another node's refresh output here to re-run the count when the store changes, and use the count to drive loops or gates downstream.
  • count is a genuine INT, so you can use it in math nodes or to decide whether to run a heavier node ("only summarize if we have documents").
  • A count of 0 with a success: true is normal - it means the collection is empty, not that it failed. Check the json output when in doubt; the node itself doesn't distinguish.

Install

ComfyUI Manager → search ComfyUI-ZMongo, or:

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

restart, and remember the pack's real dependency list is long even though this read-only node just needs the API session. First import after install takes a moment.

CategoryZMongo/02 Docs

Inputs (6)

NameTypeDefaultDescription
sessionZMONGO_API_SESSION
collection_nameSTRING
query_jsonSTRING{}
document_idSTRING
cacheBOOLEANfalse
refresh_tokenoptSTRING

Outputs (2)

NameTypeDescription
jsonSTRING
countINT