_.where
Filter a list of objects like a mini database query
- list_or_dict
- properties
- *
If you ever find yourself holding a list of dicts - say, a batch of model metadata, image info, or checkpoint records - and you want just the ones where resolution == "832x1216", _.where is the node that does it. It looks through each value in a collection and returns every element whose key/value pairs match the properties you specify. It's a WHERE clause on a list of objects, no SQL required.
It's part of the ovum/underscore family in comfy-ovum, and as with every sibling, the README's warning stands: these auto-generated underscore wrappers are "an absolute disaster to use in production," WIP. _.where is genuinely handy when it has a job to do, but the inputs are generic * sockets and the matching semantics have JS ancestors, so verify the shape of your data before you trust the output.
How it works
Underscore's where takes a list and a properties object, and keeps every item that contains all of the given key/value pairs. where([{type:"model", size:"xl"}, {type:"lora", size:"xl"}], {"size": "xl"}) → both entries; add "type": "lora" to the properties and you get just the LoRA one. It's a partial match - an item passes if it has at least the listed properties, with matching values.
The node wraps underscore3, the vendored Python port of Underscore.js, in the usual auto-generated shell. Chain mode works too: pass a _.CHAIN and it keeps the chain going rather than returning a value directly.
Inputs and output
list_or_dict- the collection to search (type*, optional; also accepts a_.CHAIN).properties- the key/value pairs to match, as JSON. This is the part people fumble: it must be an object, e.g.{"size": "xl"}, not a bare string. The tooltip notes JSON is allowed for arrays/objects where applicable.- Output:
*- the filtered list, but typed generically.
Install
Manager: search comfy-ovum, install, restart. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/sfinktah/comfy-ovum
Restart. No model downloads; underscore3 is bundled in the pack.
Where it shines
This node becomes genuinely useful the moment your workflow starts handling structured data - filtering a batch of file records by extension, narrowing model lists by type, or slicing a list of generation metadata before it fans out into a loop. It's also a good candidate for pairing with the pack's Python String Format node to build summaries of just the matching rows. Just remember: generic sockets everywhere, so keep your data shapes straight.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| list_or_dictopt | * | Primary input object (expected collection). You can still pass any JSON-serializable value. Also accepts _.CHAIN to continue chaining. | |
| propertiesopt | * | properties: JSON allowed for arrays/objects where applicable. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| * | * | — |