Query and update MongoDB collections from any Windmill script, flow or app, through the official driver.
Set up in 3 steps
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.
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.
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.
Get recently inserted documents
Find Document by Id
Search Documents
Create New Document
Delete a Document
Update a Document
Create Many New Documents
Delete Many Documents
Resource type
mongodb — the shape of the credential every script on this page expects.
| Field | Type | Required | What it is |
|---|---|---|---|
| credential | any | Yes | |
| db | string | Yes | |
| servers | any | Yes | |
| tls | boolean | Yes |
All resource types
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.