Managed MongoDB

A managed MongoDB instance — a NoSQL document database for flexible, schema-less data. MongoDB is one of the managed database services Temps runs as a container on your own infrastructure.


Creating a MongoDB Instance

Via Dashboard:

  1. Navigate to ServicesCreate Service.
  2. Select MongoDB.
  3. Choose the image:
    • MongoDB 8 (Managed + WAL-G) — the recommended default (gotempsh/mongodb-walg:8.0). This image archives mongodump snapshots to S3.
    • Custom image — bring your own (e.g. mongo:7.0). Custom images support local dumps only.
  4. Optionally enable replica set mode (see below).
  5. Click Create Service.

On creation Temps auto-assigns a host port starting from 27017, creates a dedicated Docker volume at /data/db, and generates a root user with an auto-generated password.


Manage from the CLI

Provision and manage MongoDB from the terminal with the @temps-sdk/cli tool — the same flow worked end-to-end for PostgreSQL.

Create

# Log in once (stores credentials in ~/.temps)
bunx @temps-sdk/cli login

# Create the service. Set parameters with repeatable -s key=value flags;
# if a required one is missing the CLI fails fast and names it, so you
# can add it and re-run.
bunx @temps-sdk/cli services create -t mongodb -n my-mongo -y

Inspect, link & manage

# List services and grab the numeric ID
bunx @temps-sdk/cli services list

# Full details, including the connection string
bunx @temps-sdk/cli services show --id 10

# Link to a project so MONGODB_URL (and friends) are injected on deploy
bunx @temps-sdk/cli services link --id 10 --project-id 5
bunx @temps-sdk/cli services env --id 10 --project-id 5     # see injected vars
bunx @temps-sdk/cli services unlink --id 10 --project-id 5

# Lifecycle
bunx @temps-sdk/cli services stop --id 10
bunx @temps-sdk/cli services start --id 10
bunx @temps-sdk/cli services upgrade --id 10 -v mongo:7.0
bunx @temps-sdk/cli services remove --id 10 -f             # destroys data

Connecting to MongoDB

Node.js with the MongoDB driver

import { MongoClient } from 'mongodb';

// MONGODB_URL is injected automatically when the service is linked
const client = new MongoClient(process.env.MONGODB_URL);
await client.connect();

const db = client.db(process.env.MONGODB_DATABASE);
const user = await db.collection('users').findOne({ id: userId });

Python with pymongo

import os
from pymongo import MongoClient

client = MongoClient(os.environ['MONGODB_URL'])
db = client[os.environ['MONGODB_DATABASE']]

user = db['users'].find_one({'id': user_id})

Linking to Projects

When you link a MongoDB service to a project, Temps injects these variables into the environment:

VariableDescription
MONGODB_URLFull connection string
MONGODB_HOSTContainer hostname
MONGODB_PORTPort (27017)
MONGODB_DATABASEDatabase name
MONGODB_USERNAMEUsername
MONGODB_PASSWORDPassword

Common Use Cases

  • Name
    Flexible Documents
    Description

    Store records whose shape varies between entries without migrations:

    await db.collection('events').insertOne({
      type: 'signup',
      payload: { plan: 'pro', referrer: 'docs' },
      at: new Date(),
    });
    
  • Name
    Content & Catalogs
    Description

    Model nested, hierarchical data (product catalogs, CMS content) as a single document instead of joining across tables.

  • Name
    Aggregation Pipelines
    Description

    Compute analytics in the database with the aggregation framework:

    const topPlans = await db.collection('events').aggregate([
      { $match: { type: 'signup' } },
      { $group: { _id: '$payload.plan', count: { $sum: 1 } } },
      { $sort: { count: -1 } },
    ]).toArray();
    

Backups & Durability

The managed gotempsh/mongodb-walg image archives mongodump snapshots to your configured S3 destination on a schedule you set; each backup schedule has its own retention window (in days). Custom images fall back to local dumps only. Unlike PostgreSQL, MongoDB restore is snapshot-based (latest) — there is no point-in-time recovery.

Restores are driven from the CLI:

Restore via the Temps CLI

temps services restore capabilities
temps services restore list-backups
temps services restore start

For higher availability, enable replica set mode at creation so the instance runs as a replica set rather than a single standalone node.


Monitoring

View live metrics and health in the dashboard's Services section — CPU & memory usage, connection count, disk usage, and uptime. Service-level monitoring is not yet exposed through the CLI.


Resource Limits

You can cap how much memory, swap, and CPU the service's container is allowed to use, and inspect what it's actually consuming. A service with no limits set runs unconstrained (the default). The same controls apply to every managed service type — PostgreSQL (standalone and cluster), MongoDB, Redis, RustFS, and S3.

The service detail page shows a Resources card that polls runtime status every 30 seconds and live usage every 5 seconds, plus an Edit limits dialog.

Editing limits

Open Services → select the service → Resources card → Edit limits. The dialog has independent Memory and CPU toggles:

FieldMeaningEmpty / off
MemoryHard memory cap, in MiBUnlimited
SwapExtra swap above the memory cap, in MiBNo extra swap
CPUCPU cap, in coresUnlimited

Endpoints

All served under the /api prefix:

GET   /api/external-services/{id}/runtime
GET   /api/external-services/{id}/stats
PATCH /api/external-services/{id}/resources
  • GET …/runtime (ExternalServicesRead) — a per-container docker inspect snapshot: status, restart_count (a steady climb signals a crash loop), oom_killed, last exit_code, image, and the limits actually applied (so you can detect drift between configured and live caps).
  • GET …/stats (ExternalServicesRead) — a one-shot CPU/memory usage sample per container, cheap enough to poll every 5–10s. memory_percent is measured against the memory limit when one is set, or against host RAM otherwise.
  • PATCH …/resources (ExternalServicesWrite) — persists the caps to the service's encrypted config and live-applies them via Docker's update API (no restart needed). A request where every field is null removes all limits.

Security

  • Name
    Network Isolation
    Description
    • Reachable only from containers on the same Temps internal network — the port is never exposed to the public internet
    • Apps connect using the container name as the host, over private networking
    • Credentials are auto-generated at creation; you never have to choose a password
  • Name
    Credential Handling
    Description
    • Temps injects credentials as environment variables when the service is linked — never hard-code them
    • Credentials are stored encrypted at rest (see Encryption below)
    • Rotate them from Services → select service → Rotate Credentials; linked projects update automatically

Encryption

Credentials (passwords, access keys) are encrypted with AES-256-GCM before being written to the Temps database. The key lives at ~/.temps/encryption_key — protect this file and back it up separately from the database.

Database contents are not encrypted at the application layer by default. For encryption at rest, enable it at the infrastructure level — encrypted volumes or LUKS on bare metal; Temps does not manage disk encryption. In transit, traffic stays on the internal Docker network and is never exposed to the public internet.


Deleting the Service

  1. Download a backupServices → select the service → Backups → download the latest.
  2. Unlink all projects so no running app still holds a reference to the credentials.
  3. Delete the service from its settings page and confirm.

Pricing & Ownership

Because the service runs on your own infrastructure, there are no per-GB storage charges, connection caps, or metered bandwidth fees. A recommended starting allocation:

TierAllocation
Small1 GB RAM, 10 GB storage
Medium2 GB RAM, 50 GB storage
Large4 GB+ RAM, 200 GB+ storage

MongoDB is built in — Vercel and Netlify are external-only, while Railway includes it. Your data never leaves your server; Temps (the company) has no access to it. See Data Ownership & Privacy for the full policy, including GDPR.

Was this page helpful?