MongoDB

Databases Servers and credentials Windmill docs

Query and update MongoDB collections from any Windmill script, flow or app, through the official driver.

Set up in 3 steps

1

Collect the connection details

From Atlas or your own deployment: the hosts and ports of the servers, the database name, and a database user's username and password. Note which database that user authenticates against — often admin rather than the one you query.

2

Add the resource in Windmill

Open Resources, add a resource of type mongodb. servers is a list of host and port pairs, credential holds the username, password and its auth database. Leave tls on unless the deployment does not offer it.

3

Run your first script

Fork any script below and read a collection before writing anything.

Scripts

Building blocks, if none of the projects above fit. Fork one, run it, or call it as a step inside your own flow.

Submit a script →

Trigger flows from MongoDB

MongoDB is not only a destination. These inbound paths are supported today.

New documents (scheduled poll)

The Get recently inserted documents trigger script polls a collection and returns the documents inserted since its last run. To run it, open a flow, add a trigger and choose Scheduled Poll, then pick the trigger script and an interval. Windmill puts the script first in the flow with a loop after it, so the steps you add run once per new item. The cursor is saved per flow: two flows polling the same source each get every item, and test runs keep a cursor of their own.

Resource types

The credential shapes the scripts on this page expect — pick the one your script asks for.

FieldTypeRequiredWhat it is
credentialanyYes
dbstringYes
serversanyYes
tlsbooleanYes

mongodb_rest

View raw schema →
FieldTypeRequiredWhat it is
endpointstringYesFor example: https://data.mongodb-api.com/app/<APP_ID>/endpoint/data/v1
api_keystringYes

Questions

Authentication fails with the right password

The auth database is usually wrong. A user created in admin authenticates against admin, whatever database you then query.

Do I need an external database at all?

Not always. Windmill data tables are managed relational storage, scoped to a workspace, with nothing to configure. Reach for MongoDB when the database already exists, or when you want its document model rather than SQL.

Atlas refuses the connection

Atlas allows only the addresses on its access list. Your workers' egress address has to be on it.

Are my credentials stored on the hub?

Never. They live only in your own Windmill workspace, encrypted at rest.