MongoDB Memory Adapter
Overview
The MongoDB Memory adapter provides a MongoDB-compatible query API backed by a local data directory. It is designed for read models that benefit from document-style queries — find, sort, skip, limit, and collection-based access.
Supported Features
| Feature | Supported |
|---|---|
| Event Store | — |
| Read Model | Yes |
| Policy DLQ | — |
| Process Manager DLQ | — |
| Scheduling | — |
When to Use
- Development environments where you want MongoDB-style query semantics without running a MongoDB server.
- Read models with document-oriented query patterns — filtering, sorting, pagination, and nested document queries.
Note: This adapter is intended for development and testing. For production MongoDB needs, consider connecting to a dedicated MongoDB instance.
Configuration
read: {
"users-directory": {
type: "mongodb-memory",
path: "./db/users-directory-mongo",
dbName: "bounda",
},
}
| Option | Type | Description |
|---|---|---|
type | "mongodb-memory" | Adapter type |
path | string | Local directory for data persistence |
dbName | string | Database name used within the MongoDB instance |
Query API
Queries against a MongoDB Memory read model have access to MongoDB-style operations:
export const handler: Query.HandlerFunction = async ({ db }) => {
const users = await db
.collection("users")
.find({ status: "active" })
.sort({ createdAt: -1 })
.skip(0)
.limit(10)
.toArray();
return users;
};
Complete Example
import type { Config } from "@bounda-dev/config";
export default {
domain: {
user: {
eventStore: { type: "in-memory" },
},
},
read: {
"users-directory": {
type: "mongodb-memory",
path: "./db/users-directory-mongo",
dbName: "bounda",
},
},
} satisfies Config;
Related
- Adapters Overview — Comparison of all available adapters
- SQLite — Relational alternative for read models
- PostgreSQL — Production-grade relational alternative
- Configuration Reference — Full config reference