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
| Field | Description |
|---|---|
| Name | Connection identifier. |
| Host / Port | Server address; 27017 by default. |
| Database | Default database for operations on this connection. |
| Username / Password | Credentials. Encrypted at rest, never returned to the browser. |
| Auth source | The database holding the user, usually admin. |
| URI | Full connection string, as an alternative to the fields above. Use it for replica sets, SRV records and Atlas. |
| AI username / password | Optional 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:
| Operation | Notes |
|---|---|
| find | Filter, projection, sort, limit, skip. |
| insert | One document or many. |
| update | Filter plus update document; optional upsert. |
| delete | Filter-based. |
{ "line": "L1", "ts": { "$gte": "2026-01-01T00:00:00Z" }, "status": "complete" }
{ "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 MongoDB | Fits SQL |
|---|---|
| Documents whose fields vary by product or recipe | Fixed, relational records |
| Nested structures you read and write whole | Data joined across many tables |
| Rapidly evolving schema during commissioning | Reporting tools that expect SQL |
| Event payloads with arbitrary detail | Anything 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
| Symptom | Check |
|---|---|
| Authentication fails | authSource — the user usually lives in admin, not in the target database. |
| Connects to a replica set then times out | Members advertise internal hostnames the QUBIQ host cannot resolve. Fix DNS or use the SRV URI. |
| Works from a shell, not from QUBIQ | The account may be restricted by source host, or lacks rights on the specific collection. |
| Writes appear then vanish | Read preference pointing at a secondary with replication lag; read from the primary to confirm. |
| Slow finds | Missing index on the filter fields. |
Next
→ QuestDB