Skip to main content
Database connectors let Devset connect to your MongoDB instances so that workflow stages can query live data as part of a test run. Rather than hardcoding a connection string inside every workflow, you register a named connector once and then reference it by name in any query block. This makes it straightforward to reuse the same workflow against different databases — local, shared, or CI — by changing only the connector name.

Add a Database Connector via the Settings UI

1

Open Settings

Navigate to Settings in the Devset UI (http://localhost:8082).
2

Select the Databases tab

Click the Databases tab. Any connectors you have already created are listed here.
3

Fill in the connector form

Click Add Connector and complete the fields for a MongoDB connection. See the field reference below.
4

Save

Click Save. The connector is stored in Devset’s local SQLite database and is immediately available to workflow definitions.

MongoDB Connector Field Reference

type
string
required
Must be "mongodb". This tells Devset which driver to use when establishing the connection.
name
string
required
A unique identifier for this connector. Workflow query blocks reference this connector by setting connection to this value. Use a descriptive slug such as local-mongo or prod-users-db.
connectionString
string
required
The MongoDB connection URI, for example mongodb://localhost:27017. For Atlas or authenticated clusters, include credentials in the URI or use the username and password fields below.
database
string
The default database to use when a query block does not specify one explicitly. If omitted, the query block must include a database field.
username
string
The username for authenticating with MongoDB. Leave blank if authentication is handled through the connection string or if the instance requires no credentials.
password
string
The password for the specified username. Leave blank when authentication is not required.

Use a Database Connector in a Workflow Query Block

After saving a connector, reference it inside a workflow stage’s query block by setting connection to the connector’s name. The query block fetches documents from MongoDB and maps fields into the workflow’s state, making the data available to subsequent stages.
"query": {
  "connection": "local-mongo",
  "database": "mydb",
  "collection": "users",
  "find": { "id": { "$path": "state.entity.id" } },
  "select": { "entity.name": "name" }
}

Query Block Field Reference

connection
string
required
The name of the database connector to use for this query.
database
string
The MongoDB database to query. Overrides the default database set on the connector. Required if no default database was configured on the connector.
collection
string
required
The name of the MongoDB collection to query.
find
object
required
A MongoDB filter document. You can use the $path operator to resolve values dynamically from the current workflow state. For example, { "$path": "state.entity.id" } substitutes the value of state.entity.id at query time.
select
object
A mapping from source document field paths to state keys. Each key is a dot-notated path in the returned document; each value is the key under which that field is stored in the workflow state. For example, { "entity.name": "name" } reads entity.name from the document and stores it as name in the workflow state.
The find filter uses standard MongoDB query operators. The $path operator is a Devset-specific extension that lets you inject runtime state values into the filter before the query is sent to MongoDB.

API Reference

You can manage database connectors programmatically using the Devset REST API.

Create a Database Connector

curl -X POST http://localhost:8082/db/connectors/configurations \
  -H "Content-Type: application/json" \
  -d '{
    "type": "mongodb",
    "name": "local-mongo",
    "connectionString": "mongodb://localhost:27017",
    "database": "mydb"
  }'

List All Database Connectors

curl http://localhost:8082/db/connectors/configurations

Delete a Database Connector

Replace {type} with mongodb and {name} with the connector’s name.
curl -X DELETE http://localhost:8082/db/connectors/configurations/mongodb/local-mongo
Deleting a connector does not update workflow definitions that reference it. Workflows with a query block pointing to a deleted connector will fail at runtime. Remove or update those references before deleting the connector.