swift-mongodb
is a pure-Swift BSON library and MongoDB driver. All of the constituent products in this package are Foundation-free.
TODO: add more snippets
import NIOCore
import NIOPosix
import MongoDB
let executors:MultiThreadedEventLoopGroup = .init(numberOfThreads: 2)
let bootstrap:Mongo.DriverBootstrap = MongoDB / ["mongo-0", "mongo-1"] /?
{
$0.executors = .shared(executors)
$0.appname = "example app"
}
let configuration:Mongo.ReplicaSetConfiguration = try await bootstrap.withSessionPool
{
try await $0.run(
command: Mongo.ReplicaSetGetConfiguration.init(),
against: .admin)
}
print(configuration)
// ...
This package requires Swift 6.0 or greater.
This library is Apache 2.0 licensed. It originally began as a re-write of MongoKitten by Joannis Orlandos and Robbert Brandsma.
I have verified that all products depended-upon by this package are Foundation-free when compiled for a linux target. Note that some package dependencies do vend products that import Foundation, but swift links binaries at the product level, and this library does not depend on any such products.
My packages:
-
Rationale: this package provides the
TraceableErrors
module which the driver uses to provide rich diagnostics. The driver does not depend on any parser targets. -
Rationale: this package implements cryptographic algorithms the driver uses to complete authentication with
mongod
/mongos
servers.
Other packages:
-
Rationale: this package provides atomic types that improve the performance of the driver’s various concurrent data structures.
-
Rationale: this package provides data structures that improve the runtime complexity of several algorithms the driver uses internally. Moreover, the driver’s
swift-nio
dependency already depends on one of this package’s modules (DequeModule
) anyway. -
Rationale: networking.
-
Rationale: networking.
Note: This library depends on the
NIOSSL
product fromswift-nio-ssl
, which imports Foundation on Apple platforms only.NIOSSL
is Foundation-free on all other platforms.