Watch keynotes and sessions from MongoDB.live, our virtual developer conference.

MongoDB Swift Driver 1.0 Released

Today I’m very pleased to announce our 1.0 release.

Our API is now stable, and from this point forward we’ll follow semantic versioning.

For more details on the driver, please check out this blog post.

We’d like to thank the following people for helping us get to this release out:

  • @valeriomazzeo for raising #458, which led to the fix introduced in SWIFT-824 - as well as for opening various other issues over time!
  • @weissi and lukasa for advice on fixing the issue encountered in SWIFT-779
  • The Swift Server Work Group for their thoughtful feedback and help moving through the SSWG pitch and proposal process (@tanner0101, @loganwright, @weissi, @tomerd)
  • Numerous others who have contributed code, feedback, and bug reports to the driver over the last 2 years!

This release was preceded by 2 release candidates (rc0, rc1); if you are upgrading from an earlier version of the driver, please see their respective release notes for details on what has changed since v0.3.0.

Below are some changes of note we’ve made, as well as a list of all tickets we’ve closed since 1.0.0-rc1.

Notable Changes

macOS Version Support

The minimum macOS version the driver now supports is 10.14.

Errors

To improve the discoverability of driver error types, their definitions have now all been nested in an enumeration MongoError. The old protocol MongoError has been renamed MongoErrorProtocol. Additionally, a separate namespace and set of errors have been introduced for use within the BSON library. Please see our error handling guide for more details.

BSON API

We’ve made some naming changes to the BSON library to prevent collisions with other libraries as well as to provide more consistency within the library as a whole. Please see the migration guide section of our BSON guide for details on upgrading from 1.0.0-rc1’s API.

Renamed Types

In addition to prefixing some types in the BSON library, we’ve also made the following renames in the driver:

  • ClientOptions is now MongoClientOptions
  • DatabaseOptions is now MongoDatabaseOptions
  • CollectionOptions is now MongoCollectionOptions
  • Hint is now IndexHint
  • Address is now ServerAddress
  • CursorType is now MongoCursorType
  • The enum case WriteConcern.W.tag is now WriteConcern.W.custom

Initial Replica Set Discovery Behavior

The driver’s behavior around initial discovery of replica set members has changed as of SWIFT-742.

Consider the following scenario: you have a three-node replica set with hosts running at localhost:27017, localhost:27018, and localhost:27019.
Previously, given a connection string containing a single one of those hosts (e.g. mongodb://localhost:27017) the driver would make a direct connection to that host only, and would not attempt to discover or monitor other members of the replica set.

The driver’s default behavior is now to automatically attempt discovery of the entire replica set when given a single host.

If you need to establish a direction connection, you can use the new connection string option directConnection=true, or set MongoClientOptions.directConnection to true. Omitting the option is equivalent to setting it to false.

More Complex Vapor Example Application

We’ve added a new Vapor example, demonstrating how to use the driver within the context of a CRUD application. If you have any suggestions for improvement or other example code you’d like to see added, please let us know!

Included Tickets

Bug

  • [SWIFT-779] - Investigate issue with 5.2 release mode C interop
  • [SWIFT-824] - Use stack allocated bson_ts for all reply documents
  • [SWIFT-761] - Fix thread sanitizer warnings

Task

  • [SWIFT-826] - Make Date(msSinceEpoch:) internal
  • [SWIFT-850] - Rename Id -> ID
  • [SWIFT-851] - Namespace all error types within an enum
  • [SWIFT-855] - Drop support for macOS versions < 10.14
  • [SWIFT-870] - Add default value for BSON.objectID case
  • [SWIFT-878] - Define BSON specific error types

Improvement

  • [SWIFT-742] - Unify behavior around configuration for replica set discovery
  • [SWIFT-204] - Suppress “ns not found” errors in MongoCollection.drop()
  • [SWIFT-769] - localizedDescription of errors should contain error message
  • [SWIFT-815] - More convenient API for ReadConcern/WriteConcern creation
  • [SWIFT-822] - Add prefixes to public type names where needed
  • [SWIFT-827] - Rewrite enums with .other case as structs
  • [SWIFT-835] - Standardize on conversion method names
  • [SWIFT-863] - Rename WriteConcern.W tag case to custom
  • [SWIFT-882] - Rewrite extJSON properties as functions
  • [SWIFT-640] - Add authentication options to MongoClientOptions
2 Likes