Skip to main content
Version: Next

MongoDB

MongoDB suits the parts of an industrial application that do not fit a fixed schema: batch records, recipe documents, per-device configuration blobs, inspection results with varying fields, event payloads.

Configuration

FieldDescription
NameConnection identifier.
Host / PortServer address; 27017 by default.
DatabaseDefault database for operations on this connection.
Username / PasswordCredentials. Encrypted at rest, never returned to the browser.
Auth sourceThe database holding the user, usually admin.
URIFull connection string, as an alternative to the fields above. Use it for replica sets, SRV records and Atlas.
AI username / passwordOptional read-only credential for the AI assistant.

Using a URI

For anything beyond a single host, supply the URI:

mongodb://user:pass@host1:27017,host2:27017/mydb?replicaSet=rs0&authSource=admin
mongodb+srv://user:pass@cluster.example.mongodb.net/mydb?retryWrites=true&w=majority

The driver's own topology discovery (SDAM) then handles failover, and QUBIQ's connection monitor reads its events for health — so a replica-set election shows up as a health blip, not an outage.

Operations

The MongoDB pipeline node and the scripting API expose:

OperationNotes
findFilter, projection, sort, limit, skip.
insertOne document or many.
updateFilter plus update document; optional upsert.
deleteFilter-based.
find — filter
{ "line": "L1", "ts": { "$gte": "2026-01-01T00:00:00Z" }, "status": "complete" }
update — filter and update
{ "filter": { "batchId": "B-1042" },
"update": { "$set": { "status": "released", "releasedBy": "operator1" } } }

Browsing

Browse (needs View connections) lists databases and collections, and samples documents so you can see the actual field names — which, in a schemaless store, is the only reliable way to know them.

Writing from pipelines

MongoDB writes issued by a pipeline are covered by store-and-forward: buffered while the server is unreachable, replayed in order, quarantined if they fail permanently.

Because replay is possible, make writes idempotent where you can. An update with a filter is naturally idempotent; a bare insert is not. Use a deterministic _id or an upsert when the same logical event might be replayed.

Indexing

Two indexes cover most industrial usage:

  • The time field, for range queries driving trends and reports.
  • The equipment or line identifier, usually compound with time: { line: 1, ts: -1 }.

Without them, a "last 24 hours for line 1" query becomes a collection scan, and it will be slow exactly when the collection has grown enough to matter.

Choosing MongoDB over SQL

Fits MongoDBFits SQL
Documents whose fields vary by product or recipeFixed, relational records
Nested structures you read and write wholeData joined across many tables
Rapidly evolving schema during commissioningReporting tools that expect SQL
Event payloads with arbitrary detailAnything requiring multi-row transactions

For tag time-series, use neither — use the historian, which is built for it.

Security

  • Create a dedicated user with rights on one database, not a cluster-wide root account.
  • Set the AI credential to a read-only user if the assistant may touch this connection.
  • Enable TLS in the URI (tls=true) on any network you do not fully control.
  • Filters coming from user input are treated as data, not merged into a query string — but validate ranges and expected shapes anyway.

Troubleshooting

SymptomCheck
Authentication failsauthSource — the user usually lives in admin, not in the target database.
Connects to a replica set then times outMembers advertise internal hostnames the QUBIQ host cannot resolve. Fix DNS or use the SRV URI.
Works from a shell, not from QUBIQThe account may be restricted by source host, or lacks rights on the specific collection.
Writes appear then vanishRead preference pointing at a secondary with replication lag; read from the primary to confirm.
Slow findsMissing index on the filter fields.

Next

QuestDB