Database service

MongoDB

The MongoDB integration attaches a database on an existing MongoDB server — a Dreambase-managed shared server or your own dedicated one — and exposes it to the rest of your project for document CRUD via function calls.

MongoDB is one of the Database service integrations. It handles its own webhook route:

POST/mongo/webhook
Connect to an existing / shared MongoDB server

What it does

On DEPLOYMENT_CREATED the service connects to the configured MongoDB server, ensures the requested database exists, and publishes its connection string back to Dreambase as the url output — ready for other services to consume. It also answers health checks, reports storage metrics, and runs document operations on demand through function calls.

Attach vs. provision

The mongo route attaches a new database on an existing shared server. To spawn and manage a server process yourself, use the MongoDB Server integration instead.

Inputs

InputRequiredDescription
serverTypeyesshared (default) uses a Dreambase-managed MongoDB server — no setup, ideal for MVPs and development. dedicated connects to your own server.
protocoldedicatedConnection protocol — mongodb+srv (default) for MongoDB Atlas / DNS seedlist clusters, or mongodb for a standard host:port connection. Shown only when serverType is dedicated.
hostdedicatedServer host, optionally including a port (e.g. cloudcluster.zwkzy2t.mongodb.net or localhost:27017). Don't include the protocol, credentials, database name, or query string.
usernamenoDatabase user name. Leave blank if the server requires no authentication.
passwordnoDatabase user password. Leave blank if the server requires no authentication.
optionsnoOptional connection-string query parameters, without the leading ? (e.g. appName=CloudCluster&retryWrites=true).
databaseyesName of the database to create and use.

From a connection string

For a dedicated server the parts are assembled into <protocol>://<username>:<password>@<host>/?<options> (credentials URL-encoded), then the database name is inserted before the query string. So a connection string like mongodb+srv://db_user:db_pass@cloudcluster.zwkzy2t.mongodb.net/?appName=CloudCluster maps to protocol=mongodb+srv, host=cloudcluster.zwkzy2t.mongodb.net, username=db_user, password=db_pass, and options=appName=CloudCluster.

Outputs

  • url — the MongoDB connection string, available to other services.

Functions

Other services can call these via a FUNCTION_CALL event:

  • insertDocument — insert a document into a collection.
  • findDocuments — find documents matching a filter (with limit, skip, sort).
  • findDocument — find a single document matching a filter.
  • updateDocument — update the first matching document.
  • updateDocuments — update all matching documents.
  • deleteDocument — delete the first matching document.
  • deleteDocuments — delete all matching documents.
  • countDocuments — count documents matching a filter.

Metrics

  • number_of_collections — total collections in the database.
  • number_of_documents — total documents across all collections.
  • storage_size — storage used by the database, in bytes.

Events it handles

  • WEBHOOK_CHALLENGE — verify the webhook endpoint.
  • HEALTH_CHECK — confirm the database is reachable.
  • METRIC_UPDATE — report collection, document, and storage metrics.
  • DEPLOYMENT_CREATED — attach the database and return its connection string.
  • DEPLOYMENT_DELETED — tear the database down.
  • DOWNLOAD_STARTED — signal that a build/download has begun.
  • FUNCTION_CALL — run a named document function.