MongoDB Scala Driver¶
Introduction¶
This is the officially supported Scala driver for MongoDB.
It's a modern idiomatic Scala driver with asynchronous and non-blocking IO.
Installation¶
The recommended way to get started using the driver in your project is
with a dependency management system like sbt
or maven
. See the
Installation Guide
for more information.
Connect to MongoDB Atlas¶
To connect to a MongoDB Atlas cluster, use the Atlas connection string for your cluster:
import org.mongodb.scala._ // ... val uri: String = "mongodb+srv://<username>:<password>@<cluster-address>/test?retryWrites=true&w=majority" System.setProperty("org.mongodb.async.type", "netty") val client: MongoClient = MongoClient(uri) val db: MongoDatabase = client.getDatabase("test")
See our guide on Connecting for more ways to connect.
Compatibility¶
MongoDB Compatibility¶
Scala Driver | MongoDB 4.4 | MongoDB 4.2 | MongoDB 4.0 | MongoDB 3.6 | MongoDB 3.4 | MongoDB 3.2 | MongoDB 3.0 | MongoDB 2.6 |
---|---|---|---|---|---|---|---|---|
4.2 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
4.1 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
2.9 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | |
2.8 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | |
2.7 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | |
2.6 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ||
2.5 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ||
2.4 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ||
2.3 | ✓ | ✓ | ✓ | ✓ | ✓ | |||
2.2 | ✓ | ✓ | ✓ | ✓ | ✓ | |||
2.1 | ✓ | ✓ | ✓ | ✓ | ||||
2.0 | ✓ | ✓ | ✓ | ✓ | ||||
1.2 | ✓ | ✓ | ✓ | ✓ | ||||
1.1 | ✓ | ✓ | ✓ | |||||
1.0 | ✓ | ✓ |
The driver does not support older versions of MongoDB.
Language Compatibility¶
Scala Driver | Scala 2.13 | Scala 2.12 | Scala 2.11 |
---|---|---|---|
4.2 | ✓ | ✓ | ✓ |
4.1 | ✓ | ✓ | ✓ |
2.9 | ✓ | ✓ | ✓ |
2.8 | ✓ | ✓ | ✓ |
2.7 | ✓ | ✓ | ✓ |
2.6 | ✓ | ✓ | |
2.5 | ✓ | ✓ | |
2.4 | ✓ | ✓ | |
2.3 | ✓ | ✓ | |
2.2 | ✓ | ✓ | |
2.1 | ✓ | ✓ | |
2.0 | ✓ | ✓ | |
1.1 | ✓ | ✓ | |
1.1 | ✓ | ||
1.0 | ✓ |
For more information on how to read the compatibility tables, see our guide on MongoDB Compatibility Tables.
How to get help¶
- Ask questions on our MongoDB Community Forums.
- Visit our Support Channels.
- See Issues & Help.
Give Feedback