Skip to the content
Documentation
Help Start
Reading in:
  • German: 9,155 of 9,155 pages
About the help in other languages
All help pages

Databases that speak the MongoDB protocol

This page is for administrators who want to run Exponential on a database that speaks the MongoDB wire protocol but is not MongoDB, and for developers who work on its driver: FerretDB, Amazon DocumentDB and Azure Cosmos…

Download as PDF

Address: https://doc.exponential.earth/learninminutes/exphelp/viewer/features/6.0/mongodb-wire-databases.md

On this page

Databases that speak the MongoDB protocol

This page is for administrators who want to run Exponential on a database that speaks the MongoDB wire protocol but is not MongoDB, and for developers who work on its driver: FerretDB, Amazon DocumentDB and Azure Cosmos DB for MongoDB (request units and vCore). From Exponential 6.0.15 the kernel has a driver for each of them. Every one is the MongoDB adapter expMongoDB with a profile of what its database does differently (expMongoWireProfile), so the kernel treats the database as MongoDB.

Status. FerretDB 2 runs a whole site (measured on FerretDB 2.7.0 over PostgreSQL 17 with the DocumentDB extension, in the GitHub workflow "MongoDB wire databases", beside MongoDB 5.0 as the reference). Amazon DocumentDB and Azure Cosmos DB for MongoDB (request units and vCore) have their drivers and profiles, written from the vendors' documentation and support tables, and are not measured: DocumentDB has no emulator, and the Linux emulator of Cosmos DB with the MongoDB API stops at start ("The evaluation period has expired", 28 November 2026) while its successor (vnext-preview) has the API for NoSQL only.

Contents

The databases

DatabaseDatabaseImplementationPortLevelTested
MongoDB 4.0 and latermongodb (expMongoDB)27017full siteyes; 5.0.33 in the workflow, with the bitwise operators written as arithmetic
FerretDB 2 (PostgreSQL with the DocumentDB extension)ferretdb (expFerretDB)27017full site (measured)FerretDB 2.7.0: the probe of the 18 operators the adapter uses, all answered; install.php --db=ferretdb with the site package, front page and admin login 200
Amazon DocumentDB 5.0documentdb (expDocumentDB)27017, TLSdata tables expectedno: no emulator
Azure Cosmos DB for MongoDB, request units (4.2)cosmosdb (expCosmosMongoDB)10255, TLSdata tables expectedno: the emulator's evaluation period has expired
Azure Cosmos DB for MongoDB vCorecosmosdbvcore (expCosmosVCoreDB)10260, TLSfull site expectedno: no emulator; its engine is DocumentDB, the one FerretDB 2 runs on, so FerretDB's result is the closest measure

FerretDB 1 (over plain PostgreSQL or SQLite) has no $lookup and cannot hold a site.

Settings

site.ini [DatabaseSettings] gives Server, Port, User, Password and Database as for MongoDB; an empty Port is the profile's. [MongoWireSettings]:

SettingMeaning
Profileempty: the driver's own profile; mongodb, ferretdb, documentdb, cosmosdb or cosmosdbvcore
TLSenabled, disabled; empty: the profile's (on for DocumentDB and Cosmos DB)
TLSCAFilethe CA bundle, e.g. Amazon's global-bundle.pem for DocumentDB
ReplicaSetempty: the profile's (rs0 for DocumentDB); none: no replica set
RetryWritesenabled, disabled; empty: the profile's (off for FerretDB, DocumentDB and Cosmos DB)
AuthSource, ReadPreferencewritten into the connection URI when set
URIOptions[]more options, name=value each, e.g. URIOptions[]=tlsAllowInvalidCertificates=true for the Cosmos DB emulator

What the profiles change

  • Bitwise aggregation operators. The kernel filters language masks with $bitAnd (and the SQL translation writes $bitAnd, $bitOr, $bitXor, $bitNot). MongoDB has them only from 6.3; FerretDB, DocumentDB and Cosmos DB not at all. Where the server lacks them, the driver writes them as arithmetic ($mod, $floor, $divide) whenever one side is a constant, which every kernel mask is. This also makes MongoDB 4.0 to 6.2 work as the wizard promises.
  • Retryable writes. DocumentDB and Cosmos DB refuse them; the driver writes retryWrites=false into the URI.
  • TLS and the replica set are written into the URI from the profile and the settings.
  • Sorting on Cosmos DB. Cosmos DB (request units) sorts only on an indexed field: the driver indexes every column of each table it creates (exp_sort_<column>), while the collection is still empty, as Cosmos DB requires of unique indexes too.
  • $lookup with let and pipeline. The kernel uses it in 19 places. DocumentDB and Cosmos DB (request units) refuse it; the driver logs a warning naming the table. This is why both are expected at the data tables level.
  • Transactions are not used by the adapter; no profile depends on them.
  • $bitsAnySet on Cosmos DB. Cosmos DB (request units) has no bitwise query operators; the driver writes { field: { $bitsAnySet: mask } } as an $expr with the same arithmetic.
  • DocumentDB 8.0. Engine 8.0 adds the bitwise aggregation operators (8.0.1), correlated subqueries and retryable writes (8.0.2). On such a cluster [MongoWireSettings] Profile=mongodb with TLS=enabled uses them natively.
  • FerretDB and logins. PHP's mongodb extension (libmongoc) refuses the 16-byte SCRAM salt of the PostgreSQL users FerretDB 2 logs in ("invalid salt length of 16"). Run FerretDB without authentication (FERRETDB_AUTH=false) on a private network or a Unix socket, with the PostgreSQL login behind it.

Installing a site

The setup wizard lists the databases right after MongoDB when PHP has the mongodb extension; the kickstarter takes ferretdb, documentdb, cosmosdb and cosmosdbvcore as Type of [database_choice].

Tests

  • php vendor/bin/phpunit --testsuite mongowire: the profiles, the arithmetic of the bitwise operators against PHP's own, the connection URI and the sort indexes, without a server.
  • mongowire-live: against a server of EXP_MONGOWIRE_URI with EXP_MONGOWIRE_PROFILE.
  • The GitHub workflow "MongoDB wire databases" (.github/workflows/mongowire.yml) runs both suites against FerretDB 2 and MongoDB 5.0 in containers, then installs the site package with install.php and renders the front page and the admin login. The errors the install logs are the same on both, so none comes from FerretDB.

Something wrong on this page? Report an error

Documentation license

This documentation is free documentation, licensed under the GNU Free Documentation License 1.3 or later.

Exponential Copyright © 1998-2026 Exponential Foundation and 7x