MongoDB

What you get

A managed MongoDB 7 instance with an auto-generated root user and password, injected as MONGODB_URI (also MONGO_URL):

MONGODB_URI=mongodb://user:pass@host:port/miosa_db?authSource=admin

Standard MongoDB drivers work without modification:

import { MongoClient } from "mongodb"
const client = new MongoClient(process.env.MONGODB_URI!)
await client.connect()

const users = client.db("miosa_db").collection("users")
await users.insertOne({ name: "Ada", createdAt: new Date() })

The user has the root role, so you can create any number of databases on the instance. authSource=admin is part of the URL and must stay.

Provision

miosa db create --name app-mongo --engine mongodb
await miosa.databases.create({ name: "app-mongo", engine: "mongodb", size: "small" })

You can also choose MongoDB in the Add menu of a project, or set managed: mongodb on a database service in a change set. Only major version 7 is available.

Connection variables

VariableValue
MONGODB_URIFull connection string
MONGO_URLSame as MONGODB_URI
MONGO_HOST, MONGO_PORTHost and port
MONGO_USER, MONGO_PASSWORDRoot user and password
MONGO_DATABASEDefault database name

Backups and restore

Backups are logical (mongodump, gzip archive) and cover every database on the instance except admin and config. A restore replaces the collections the backup contains and leaves the others alone. It never touches the admin database, so your issued credentials keep working. A MongoDB backup restores only into a MongoDB database.

Limits

  • There is no table browser or query console for MongoDB. Use mongosh or a driver.
  • There is no automatic pause when idle, as with MySQL and Redis.
  • Memory, connections and storage follow the selected plan size.

See also

Was this page helpful?