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.

Resource type

mongodb — the shape of the credential every script on this page expects.

View raw schema →
FieldTypeRequiredWhat it is
credentialanyYes
dbstringYes
serversanyYes
tlsbooleanYes

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.