cookbook / mongo
MongoDB
A MongoDB server with authentication and a persistent volume.
- database
- document
Run it
briq_run({
recipe: "mongo",
params: {
"version": "8",
"size": "small"
},
wait: true
})briq run mongo
briq ls
briq logs -f <id>
briq rm <id>import { Briq } from '@briq/sdk';
const briq = new Briq(process.env.BRIQ_API_KEY);
const mongo = await briq.run({
recipe: 'mongo',
params: {
"version": "8",
"size": "small"
},
});
console.log(mongo.outputs.MONGODB_URI);
// ... when done
await briq.destroy(mongo.id);Parameters
| Name | Type | Options | Default |
|---|---|---|---|
| version | enum | 7, 8 | "8" |
| size | enum | nano, small, medium, large | "small" |
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 | 10 GB at /data/db |
When to use it
- Your code uses Mongoose, Prisma with MongoDB, or the native driver, and needs a real replica of the server behaviour: indexes, transactions, aggregation.
- Tests expect
MONGODB_URI.
Authentication is on: the output URI carries the generated root password and authSource=admin. Versions 7 and 8 (default).
Tips
- One database per test run. The URI points at
app; use a different database name per suite if you run several in parallel against the same briq. - Seed with mongosh.
briq_files_puta script to/seed.js, thenbriq_execwithmongosh "$MONGODB_URI" /seed.js. - Transactions need a replica set. The recipe runs a single node without replication. If your code requires
session.startTransaction(), ask in the cookbook issues for thereplicaSetparameter. - Data survives stop/start thanks to the 10 GB volume at
/data/db.