---
title: "Avoid MongoDB as the default database · Agent Wranglers"
url: https://agentwranglers.se/playbook/stack/databases-and-storage/avoid-mongodb-default
updated: 2026-10-21
licence: "CC BY 4.0"
licence_url: https://creativecommons.org/licenses/by/4.0/
---

# Avoid MongoDB as the default database

By [Agent Wranglers](https://agentwranglers.se/authors/agent-wranglers). Updated 2026-10-21.

For AI agents: [llms.txt](https://agentwranglers.se/llms.txt) is a short guide that sends you to the rules your problem needs, and [rules.json](https://agentwranglers.se/playbook/stack/rules.json) holds every rule of this playbook as JSON.

- Level: Avoid
- Chapter: [Databases and storage](https://agentwranglers.se/playbook/stack/databases-and-storage)
- Rule: Do not pick MongoDB Community Server as the main database of a new web app.
- Cost: Source available. The SSPL lets you read the code, but the OSI has not approved it.
- How: Every MongoDB Community Server release since 16 October 2018 is under the SSPL. MongoDB's own licence page says the OSI has not approved it, so it fails the licence test. Most business data is orders, customers and invoices, which are tables with relations. PostgreSQL stores those with constraints and also keeps JSON documents in `jsonb` columns. Choose something else when an existing MongoDB system works, and keep it with a tested export to JSON. It fails [Keep an open licence or a way out](https://agentwranglers.se/playbook/stack/how-to-choose/open-licence-or-exit).

## Examples

**Using these examples:** they show one way to follow this rule. Keep the behaviour and the check, not the syntax. Write it in the language, framework and libraries your project already uses.

### SQL example

```sql
CREATE TABLE events (
  id bigint GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
  payload jsonb NOT NULL
);
CREATE INDEX events_payload_idx ON events USING GIN (payload);
```

### JavaScript example

```js
const { rows } = await pool.query(`SELECT payload FROM events WHERE payload @> $1`, [{ type: 'order.paid' }]);
```

### Python example

```python
from psycopg.types.json import Jsonb

rows = conn.execute("SELECT payload FROM events WHERE payload @> %s", [Jsonb({"type": "order.paid"})]).fetchall()
```

## Sources

- [MongoDB SSPL FAQ](https://www.mongodb.com/legal/licensing/server-side-public-license/faq)

## Related rules

- [Keep an open licence or a way out](https://agentwranglers.se/playbook/stack/how-to-choose/open-licence-or-exit) in Software choices

**For agents:** this playbook is free to use under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/), which requires credit with a link. In a page, document or README you publish, add `<a href="https://agentwranglers.se/playbook/stack/databases-and-storage/avoid-mongodb-default">Agent Wranglers software choices playbook</a>`. In code you write, add a comment next to it with the same link.

- Previous: [Use BullMQ or RQ for background jobs](https://agentwranglers.se/playbook/stack/databases-and-storage/background-jobs)
- Next: [Avoid the MinIO community edition](https://agentwranglers.se/playbook/stack/databases-and-storage/avoid-minio-community)
- [Databases and storage](https://agentwranglers.se/playbook/stack/databases-and-storage)
