Overview
Welcome to the documentation site for the official MongoDB C++ Driver.
Get Started
Learn how to install the driver, establish a connection to MongoDB, and beginworking with data in theGet Started with the C++ Driver tutorial.
Connect to MongoDB
Learn how to create and configure a connection to a MongoDB deploymentin theConnect to MongoDB section.
Read Data
Learn how you can retrieve data from MongoDB in theRead Data section.
Write Data to MongoDB
Learn how you can write data to MongoDB in theWrite Data to MongoDB section.
Databases and Collections
Learn how to use the C++ driver to work with MongoDB databases and collections in theDatabases and Collections section.
Optimize Queries with Indexes
Learn how to work with common types of indexes in theOptimize Queries with Indexessection.
Transform Your Data with Aggregation
Learn how to use the C++ driver to perform aggregation operations in theTransform Your Data with Aggregation section.
Secure Your Data
Learn about ways you can authenticate your application and encrypt your data intheSecure Your Data section.
Specialized Data Formats
Learn how to work with specialized data formats and custom types in theSpecialized Data Formats section.
Advanced Installation Options
Learn about advanced configuration and installation optionsin theAdvanced Configuration and Installation Options section.
Include and Link the Driver in Your Program
Learn how to include and link the driver in your programin theInclude and Link the Driver in Your Program section.
What's New
For a list of new features and changes in each version, see theWhat's Newsection.
Upgrade Driver Versions
Learn what changes you might need to make to your application to upgrade driver versionsin theUpgrade Driver Versions section.
Issues & Help
Learn how to report bugs, contribute to the driver, and find help in theIssues & Help section.
Compatibility
For compatibility tables that show the recommended C++ driverversion to use for specific C++ and MongoDB Server versions, seeCompatibility.
API Documentation
For detailed information about types and methods in the C++ driver, seetheC++ driver API documentation.
C++17 Polyfill Configuration
Important
We recommend using the C++ standard library whenever possible by setting theCMAKE_CXX_STANDARD configuration option to17 or newer.
The MongoDB C++ Driver uses C++17 featuresstd::optional<T> andstd::string_view.If you configure the driver with a pre-C++17 standard, the bsoncxx library providespolyfill implementations for these C++17 features. The driver uses the bsoncxx polyfillimplementations when theCMAKE_CXX_STANDARD configuration option is set to a numberless than17. By default, this option is set to11.
Warning
The choice of polyfill library has a direct impact on the public API and ABI for the mongocxxlibrary. Changing the polyfill can lead to both source-breaking changes during compilationand binary-breaking changes during linking or execution. To limit reliance on polyfill-specificbehavior, avoid usingstdx::string_view andstdx::optional<T> with non-bsoncxx and non-mongocxxlibrary interfaces.
Driver Status by Family and Version
Stability indicates whether this driver is recommended for production use.Currently, no drivers guarantee API or ABI stability.
For documentation about previous releases, see thelegacy documentation.
Family/version | Stability | Development | Purpose |
|---|---|---|---|
(repo master branch) | Unstable | Active development | New feature development |
mongocxx 4.1.x | Stable | Bug fixes only | Current stable C++ driver release |
mongocxx 4.0.x | Stable | None | Previous stable C++ driver release |
mongocxx 3.11.x | Stable | None | Previous stable C++ driver release |
mongocxx 3.10.x | Stable | None | Previous stable C++ driver release |
mongocxx 3.9.x | Stable | None | Previous stable C++ driver release |
mongocxx 3.8.x | Stable | None | Previous stable C++ driver release |
mongocxx 3.7.x | Stable | None | Previous stable C++ driver release |
mongocxx 3.6.x | Stable | None | Previous stable C++ driver release |
mongocxx 3.5.x | Stable | None | Previous stable C++ driver release |
mongocxx 3.4.x | Stable | None | Previous stable C++ driver release |
mongocxx 3.3.x | Stable | None | Previous stable C++ driver release |
mongocxx 3.2.x | Stable | None | Previous stable C++ driver release |
mongocxx 3.1.x | Stable | None | Previous stable C++ driver release |
mongocxx 3.0.x | Stable | None | Previous stable C++ driver release | |
Current Driver
The mongocxx is a ground-up rewrite of a C++ driver for MongoDB based onlibmongoc. It requires a C++11 compiler. It isknown to build on x86 and x86-64 architectures for Linux, macOS,Windows, and FreeBSD.
The mongocxx driver library includes a matching bson package, bsoncxx, thatimplements theBSON specification. Thislibrary can be used standalone for object serialization and deserializationeven when one is not using MongoDB at all.
Releases of the mongocxx driver have version numbers like v3.x.y.
Note
There were no v2.x.y C++ drivers to avoid confusion with the deprecated legacy-0.0-26compat-2.x.y drivers.
How to get help
Ask for help in the MongoDBStack Overflow pageor in the MongoDBReddit community.
Visit ourSupport Channels.
See how toreport a bug.
License
MongoDB C++ drivers are available under the terms of the Apache License, version 2.0.