Codesphere DocumentDB
Codesphere DocumentDB exposes a MongoDB-compatible document database powered by PostgreSQL, the DocumentDB extension, and FerretDB. It is meant for document-oriented applications that want MongoDB protocol compatibility inside Codesphere.
| Property | Value | Notes |
|---|---|---|
| Provider name | ferretdb | Use this in landscape provider definitions. |
| Version | v0 | Current schema version exposed by the provider. |
| Category | Database | Shown in the managed services catalog. |
| Scope | global | Available at team scope rather than being tied to a single workspace runtime. |
| Team singleton | false | Teams can create multiple DocumentDB service instances. |
| Pause support | true | This provider supports pausing. |
Preview Feature
This provider is currently a preview feature. It is not enabled by default and needs to be enabled by your operator. As a preview, the provider is still evolving, its schema, plans, and behavior may change in the future.
Capabilities
| Capability | Supported | Notes |
|---|---|---|
| Backups | ✅ | Backups are stored in the object store as native PostgreSQL physical backups, utilizing the standard PostgreSQL storage architecture. They are not MongoDB dumps. |
| Point-in-time recovery | ✅ | The database can be restored to a specific point in time. |
Good to know
- High availability is not yet available; the service runs as a single instance.
- Upgrades are never applied automatically.
- Storage does not grow automatically, but you can increase the
storageplan parameter manually at any time.
Architecture
A DocumentDB service consists of two components:
- PostgreSQL with the DocumentDB extension — the actual data engine. A dedicated PostgreSQL server, powered by the CloudNativePG operator, runs the open-source DocumentDB extension, which implements BSON document storage and processing inside PostgreSQL.
- FerretDB proxy — a stateless FerretDB deployment in front of the database. It speaks the MongoDB wire protocol (compatible with MongoDB 5.0+ drivers) and translates client commands into queries against the DocumentDB extension.
Your application connects to the FerretDB endpoint (the dsn, port 27017) with standard MongoDB drivers, while the data itself lives in PostgreSQL. The underlying PostgreSQL instance is directly reachable via postgresDSN for migrations and maintenance.
Things to be aware of:
- Pinned versions: The
versionconfig field pins a compatible combination of PostgreSQL major version, DocumentDB extension version, and FerretDB version — for example,17-0.107.0-ferretdb-2.7.0is PostgreSQL 17 with DocumentDB 0.107.0 and FerretDB 2.7.0. - Readiness covers both components: The
readydetail is onlytruewhen both the FerretDB proxy and the PostgreSQL instance are up and running. - Backups are in PostgreSQL format: Since the data engine is PostgreSQL, backups are stored in the object store as native PostgreSQL physical backups, not MongoDB dumps. They can be restored into a DocumentDB service, but they are not interchangeable with
mongodumparchives. - No write buffering: The proxy does not queue or buffer requests. If the PostgreSQL instance is unavailable, reads and writes fail immediately instead of being held back and retried.
- MongoDB compatibility is not complete: FerretDB supports most, but not all, MongoDB commands — for example, change streams and multi-document transactions are not available. See the FerretDB compatibility documentation for the full list.
- Shared foundation: Storage (replicated Ceph block storage) and networking work the same way as in the PostgreSQL provider.
Schema
Config
| Field | Type | Required on create | Notes |
|---|---|---|---|
version | string | No | Provider version for the Postgres, DocumentDB, and FerretDB stack. Default and only allowed value: 17-0.107.0-ferretdb-2.7.0. |
Secrets
| Field | Type | Required on create | Notes |
|---|---|---|---|
superuserPassword | string | Yes | Password for the administrative user. |
Details / Output
| Field | Type | Availability | Notes |
|---|---|---|---|
hostname | string | Exposed after provisioning | Internal hostname of the MongoDB-compatible endpoint. |
port | integer | Exposed after provisioning | MongoDB-compatible port. |
dsn | string | Exposed after provisioning | MongoDB connection string for the admin user. |
postgresHostname | string | Exposed after provisioning | Internal hostname of the underlying PostgreSQL instance. |
postgresDSN | string | Exposed after provisioning | PostgreSQL connection string for direct access to the underlying database. |
ready | boolean | Exposed after provisioning | Indicates whether the instance is ready for connections. |
Plan
The provider exposes one plan, Small (id: 0).
Example plan: Small (id: 0).
| Parameter | Type | Default | Minimum | Maximum | Static | Notes |
|---|---|---|---|---|---|---|
cpu | number | 1 | - | - | Yes | PostgreSQL CPU allocation, priced as cpu-tenths. |
memory | integer | 512 | - | - | Yes | PostgreSQL memory allocation in MiB, priced as ram-mib. |
storage | integer | 1024 | 1024 | - | No | Persistent storage in MiB, priced as storage-mib. |
ferretdbCpu | number | 1 | 1 | 1 | Yes | FerretDB CPU allocation, priced as cpu-tenths. |
ferretdbMemory | integer | 64 | 64 | 128 | Yes | FerretDB memory allocation in MiB, priced as ram-mib. |
Example in a Landscape
schemaVersion: v0.2
run:
docs-db:
provider:
name: ferretdb
version: v0
plan:
id: 0
parameters:
storage: 2048
memory: 512
cpu: 1
ferretdbMemory: 64
ferretdbCpu: 1
config:
version: "17-0.107.0-ferretdb-2.7.0"
secrets:
superuserPassword: "${{ vault.documentDbSuperuserPassword }}"
Constructing Hostnames
Landscape-managed service hostnames are deterministic and follow this structure:
ms-{providerName}-{providerVersion}-{teamId}-landscape-{workspaceId}-{serviceName}.ms-postgres
The hostname is converted to lowercase and any invalid characters are replaced with hyphens.
For the MongoDB-compatible service endpoint, the provider name is ferretdb.
If your DocumentDB service is named db, that hostname resolves to ms-ferretdb-v0-$TEAM_ID-landscape-$WORKSPACE_ID-db.ms-postgres in shell commands or ms-ferretdb-v0-${{ team.id }}-landscape-${{ workspace.id }}-db.ms-postgres in landscape templates.
For the underlying PostgreSQL endpoint, the hostname can be constructed as ms-postgres-v1-$TEAM_ID-landscape-$WORKSPACE_ID-db.ms-postgres in shell commands or ms-postgres-v1-${{ team.id }}-landscape-${{ workspace.id }}-db.ms-postgres in landscape templates.
| Provider | Version | Team ID | Workspace ID | Service Name | Hostname |
|---|---|---|---|---|---|
ferretdb | v0 | 42 | 100 | db | ms-ferretdb-v0-42-landscape-100-db.ms-postgres |
postgres | v1 | 42 | 100 | db | ms-postgres-v1-42-landscape-100-db.ms-postgres |
Example ci.yml using the constructed hostname directly in a command:
schemaVersion: v0.2
run:
db:
provider:
name: ferretdb
version: v0
plan:
id: 0
parameters:
storage: 2048
memory: 512
cpu: 1
ferretdbMemory: 64
ferretdbCpu: 1
config:
version: "17-0.107.0-ferretdb-2.7.0"
secrets:
superuserPassword: "${{ vault.documentDbSuperuserPassword }}"
api:
steps:
- command: >
mongosh "mongodb://postgres:${DOCDB_PASSWORD}@ms-ferretdb-v0-$TEAM_ID-landscape-$WORKSPACE_ID-db.ms-postgres:27017/ferretdb?authSource=postgres"
env:
DOCDB_PASSWORD: "${{ vault.documentDbSuperuserPassword }}"
Example ci.yml using the constructed hostname through an environment variable:
schemaVersion: v0.2
run:
db:
provider:
name: ferretdb
version: v0
plan:
id: 0
parameters:
storage: 2048
memory: 512
cpu: 1
ferretdbMemory: 64
ferretdbCpu: 1
config:
version: "17-0.107.0-ferretdb-2.7.0"
secrets:
superuserPassword: "${{ vault.documentDbSuperuserPassword }}"
api:
steps:
- command: >
psql "postgres://postgres:${DOCDB_PASSWORD}@${DOCDB_POSTGRES_HOST}:5432/postgres" -c "select 1"
env:
DOCDB_POSTGRES_HOST: ms-postgres-v1-${{ team.id }}-landscape-${{ workspace.id }}-db.ms-postgres
DOCDB_PASSWORD: "${{ vault.documentDbSuperuserPassword }}"
Application runtimes can use the MongoDB-compatible dsn for document workloads.
If you need direct PostgreSQL access for migrations, maintenance, or advanced extensions, use postgresDSN instead.
Both endpoints are reachable from other Codesphere runtimes, including reactives, managed containers, and Virtual Cluster workloads.
Connecting to DocumentDB
Prerequisites
Once your DocumentDB is deployed, you can connect to it from your Codesphere workspaces.
Each service lists non-sensitive connection details in their respective settings page, in the overview tab (or in the details property in the public API payload).
info
Before connecting, make sure the service is synchronized and running: in the service settings, ready must be true.
Connecting via Terminal (mongosh)
You can use mongosh to connect from your workspace terminal.
No TLS Encryption between the client and the FerretDB Proxy
# Install mongosh
nix-env -iA nixpkgs.mongosh
source ~/.nix-profile/etc/profile.d/nix.sh
# Syntax
mongosh "mongodb://<username>:<password>@<hostname>:27017/ferretdb?authSource=postgres"
# Example
db.myCollection.insertOne({ message: "Hello Codesphere!" })
Connecting via Node.js
Using the mongodb driver:
const { MongoClient } = require('mongodb');
const client = new MongoClient(
);
await client.connect();
const db = client.db('ferretdb');
const collection = db.collection('myCollection');
const result = await collection.insertOne({ message: 'Hello Codesphere!' });
console.log(result.insertedId);
await client.close();
Backups
Since the data engine of a DocumentDB service is a regular PostgreSQL server, backups work exactly like backups of the PostgreSQL provider: the CloudNativePG Barman Cloud plugin stores native PostgreSQL physical backups in your S3-compatible backup store and continuously archives the write-ahead log, enabling point-in-time recovery.
Keep in mind that backups are PostgreSQL backups, not MongoDB dumps: they can be restored into a new DocumentDB service, but they are not interchangeable with mongodump archives.
If you prefer MongoDB-native dumps, you can also create them yourself with mongodump against the service endpoint. Restoring such a dump into a DocumentDB service with mongorestore works as well, but is a manual step, it is not a flow automated by Codesphere.
Configuration, recovery, required S3 permissions, and limitations are identical to PostgreSQL — see the PostgreSQL backup documentation for examples.