MongoDB
Store and query documents in a persistent MongoDB database.
- database
- document
Guide: Connect to a database from outside
Run it
briq run mongobriq_run({ recipe: "mongo", wait: true })curl -X POST https://api.briq.cloud/v1/briqs \
-H "Authorization: Bearer $BRIQ_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"recipe": "mongo",
"wait": true
}'
# → { "briqs": [{ "id": "bq_…", … }], "outputs": { "MONGODB_URI": "…" }, … }
# ... when done, for each briq id
curl -X DELETE https://api.briq.cloud/v1/briqs/<id> \
-H "Authorization: Bearer $BRIQ_API_KEY"stack: app
services:
mongo:
recipe: mongo
# its defaults, each a field you can set:
# image: mongo:8
# size: small
# volume: { gb: 2 }Fields
| Name | Type | Options | Default |
|---|---|---|---|
| image | string | — | "mongo:8" |
| env | record | { key: string | { secret, value?, literal?, scope?, hosts?, locations? } } | {} |
| cmd | string | string[] | — | — |
| size | enum | pico, micro, nano, small, medium, large, xlarge | "small" |
| volume | object | { gb? } | {"gb":2} |
| files | record | { key: string | { base64 } } | — |
| egress | object | { hosts } | — |
Outputs
Returned by briq_run once the stack is healthy. Hosts resolve inside your team network; secrets are generated per run.
- MONGODB_URI
- mongodb://root:<MONGO_ROOT_PASSWORD>@mongo.<stack>.internal:27017/app?authSource=admin
- MONGO_HOST
- mongo.<stack>.internal
- MONGO_USER
- root
- MONGO_PASSWORD
- <MONGO_ROOT_PASSWORD>
What it runs
| Briq | Image | Ports | Size | Volume |
|---|---|---|---|---|
| mongo | mongo:8 | 27017 | small | 2 GB at /data/db |
When to use it
- Your code uses Mongoose, Prisma with MongoDB or the native driver, and needs the real server: indexes, aggregation, validation.
- Tests expect
MONGODB_URI.
Tips
- Auth is on: the URI carries the generated root password and
authSource=admin. - No transactions: it is a single node, not a replica set, so
session.startTransaction()fails. - One database per suite when several run in parallel against the same briq.
- Seed with mongosh:
briq_files_puta script to/seed.js, thenbriq_execwithsh -c 'mongosh -u root -p "$MONGO_INITDB_ROOT_PASSWORD" app /seed.js'. - Connect from outside:
briq_exposeport 27017 withprotocol: "mongodb", for mongosh or Compass. See Connect to a database from outside. - Bigger dataset? The volume starts small: set
volume: { gb: 20 }. Set it when the briq is created, and it counts toward your plan's disk.