Navigation

    MongoDB Scala Driver

    This is the officially supported Scala driver for MongoDB.

    It's a modern idiomatic Scala driver with asynchronous and non-blocking IO.

    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.

    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.

    Scala DriverMongoDB 4.4MongoDB 4.2MongoDB 4.0MongoDB 3.6MongoDB 3.4MongoDB 3.2MongoDB 3.0MongoDB 2.6
    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.

    Scala DriverScala 2.13Scala 2.12Scala 2.11
    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.

    Give Feedback