All nodes/Data/Database

DB Find

Searches documents by a MongoDB-style filter with sort/limit/skip/projection. Returns an object {docs, count}: the documents found are in docs, so a loop over the result is built on output.docs.

DB Find▶
FilterSearch results

Type in the graph: db_find

Exec

An error output can be enabled to handle failures on their own path.

Ports can be split into separate execution and data handles.

Try it

Minimal working scenario

Entry
DB Find▶
Exit▶
  • Execute + Data
Press “Copy nodes”, open the editor and hit Ctrl+V on the canvas.

Runs as pasted

When to use it

Reach for Find when you need a list of documents: tickets in the “new” state, a customer’s recent orders, one page of a catalogue. A single document looked up by key is cheaper and clearer with db_find_one, and when all you need is a number, use db_count — it never carries the documents out. Semantic search over text belongs to rag_query; this node matches exact field values.

How it works

The Filter port carries both the trigger and the filter itself. An object arriving over the edge replaces the filter from the settings; when nothing arrives (a blank string from an execution-only trigger counts as nothing) the configured filter is used. A value of any other shape — a string, a number, a list — fails the node with a clear error instead of turning into “match everything”.

The Filter, Sort and Projection fields are JSON editors, not templates: {{ … }} is not expanded there and travels into the query as an ordinary string. Build a dynamic filter upstream — a template emitting a JSON object as a string, or code_javascript returning an object — and feed it to the port.

The output holds docs (the array of documents) and count. count is the size of the returned page, not the number of matches in the collection: it is measured after limit and skip.

Common mistakes

  • Reading count as the total. The number of matching documents is a separate db_count run with the same filter.
  • Forgetting the limit. It defaults to 100, so documents “disappear” at exactly the 101st.
  • Paging without a sort. skip slices an order nobody promised, so pages start to overlap. Always set a sort when you page.
  • Mixing the projection. Including (1) and excluding (0) fields in one projection is rejected. With an including projection _id comes back anyway.
  • Sending the whole object into a template. Use {{ nodes.<id>.output.docs }}, otherwise the bookkeeping count travels downstream too.
  • A filter with no plain equality. Conditions such as $gt, $in and $regex are evaluated over the whole collection, and limit does not shorten that scan. Add at least one exact match on a top-level field.

Inputs

PortWirePayloadNotes
FilterinputExecute + Dataexecute_data—

A value arriving here REPLACES the configured value — it does not merge with it, and it must be an object (any other shape fails the node instead of being ignored). To trigger the node while keeping what you configured, wire the port's exec leg (Run) instead, and put {{ }} templates in the field itself.

Outputs

PortWirePayloadNotes
Search resultsoutputExecute + Dataexecute_dataobject

Configuration

FieldTypeDefaultDescription
Collectioncollection_idstring""

Collection ID

Filterfilterobject—

MongoDB-style filter expression.

overridden by port: input

Limitlimitinteger100

How many records to return at most.

Projectionprojectionobject—

MongoDB-style projection (1 = include, 0 = exclude).

Skipskipinteger0

How many matching records to step over before returning any — paging.

Sortsortarray<array>—

List of [field, direction] pairs where direction is 1 (asc) or -1 (desc); "asc" / "desc" are accepted too. A malformed pair fails the node — it is not dropped, so the query never runs silently unsorted.

Shared fields

Every node has these three — the platform adds them, not the node author.

  • expose_error_output — When enabled, show an execution output to connect nodes that run if this step fails.
  • split_ports_in — Show separate execution and data input handles instead of one combined port.
  • split_ports_out — Show separate execution and data output handles instead of one combined port.

Ready-made examples using this node