Navigation

MongoDB Swift Driver

Introduction

This is the official MongoDB Swift Driver.

Alpha Release

The MongoDB Swift Driver is currently in alpha.

Installation

See Installation

Connect to MongoDB Atlas

To connect to a MongoDB Atlas cluster, use the Atlas connection string for your cluster:

import MongoSwift

let client = try MongoClient("mongodb+srv://<username>:<password>@<cluster-url>/test?retryWrites=true&w=majority")
let db = client.db("test")

// your application logic
// free all resources
cleanupMongoSwift()

Compatibility

MongoDB Compatibility

Swift Driver MongoDB 4.2 MongoDB 4.0 MongoDB 3.6 MongoDB 3.4 MongoDB 3.2 MongoDB 3.0 MongoDB 2.6
0.2.0        

Language Compatibility

The MongoDB Swift driver requires Swift 5 or later.

How to get help