Skip to content

1.3.0-alpha.1

Pre-release
Pre-release
Compare
Choose a tag to compare
@kmahar kmahar released this 28 Jan 21:50
· 58 commits to main since this release

We are pleased to announce the first alpha of our 1.3.0 release, containing the following new features:

Async/Await APIs

This release adds a new async/await version of our entire API surface to allow you to start using the driver with Swift concurrency!

For example, to create a collection and insert a document:

let collection = try await db.createCollection("foo")
try await collection.insertOne(["x": 1])

We’ve also made MongoCursor and ChangeStream conform to AsyncSequence. This protocol provides a number of convenience methods for working with sequences, and enables you to consume their values via a for loop, for example:

for try await doc in try await collection.find() {
    print(doc)
}

We’ve written a blog post that discusses this in more detail, and have also updated all of our documentation and our Vapor example project to use Swift concurrency to help you get started using these new APIs.

Currently, these APIs are available for Swift 5.5.0+ developers on Linux and macOS 12. For future alpha releases we are exploring making these APIs available on older macOS versions as well where concurrency has recently become available.

Please feel free to file an issue if you run into any problems or have suggestions for improving the new APIs!

New MongoConnectionString type

This release also adds a new MongoConnectionString type modeling a MongoDB connection string, and moves the driver logic for parsing and validating a connection string, which was previously handled by the C driver, into the Swift layer.

This type conforms to LosslessStringConvertible and so can be initialized via and converted to a String , and has mutable properties to allow setting/changing values. For example:

var connStr = MongoConnectionString("mongodb://localhost:27017")
connStr.readConcern = .local
print(connStr) // prints "mongodb://localhost:27017/?readconcernlevel=local"

You can now use this type to initialize a MongoClient:

var connStr = MongoConnectionString("mongodb://localhost:27017")
connStr.readConcern = .local
let client = try MongoClient(connStr, using: yourEventLoopGroup)

Included Tickets

Below are a selected list of tickets with user-facing implications; for a full list of completed tickets see this Jira query.

New Feature

  • [ SWIFT-1160 ] - Introduce new MongoConnectionString type
  • [ SWIFT-1161 ] - MongoConnectionString authentication options support
  • [ SWIFT-1162 ] - MongoConnectionString TLS options support
  • [ SWIFT-1163 ] - MongoConnectionString non-auth, non-TLS options support
  • [ SWIFT-1165 ] - Initialization of MongoClient via MongoConnectionString
  • [ SWIFT-1174 ] - MongoConnectionString Unix domain socket support
  • [ SWIFT-1384 ] - Support ‘let’ option for multiple CRUD commands
  • [ SWIFT-1389 ] - Implement MongoClient and ClientSession async/await APIs
  • [ SWIFT-1390 ] - Implement MongoDatabase async/await API methods
  • [ SWIFT-1391 ] - Implement MongoCollection async/await API methods
  • [ SWIFT-1392 ] - Make MongoCursor and ChangeStream conform to AsyncSequence
  • [ SWIFT-1405 ] - Implement description for MongoConnectionString
  • [ SWIFT-1407 ] - Support ipv4 address parsing in MongoConnectionString

Improvement

  • [ SWIFT-1451 ] - Use -cross-module-optimization flag in Vapor example