Swiftpack.co - tayloraswift/swift-mongodb as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by tayloraswift.
tayloraswift/swift-mongodb v0.7.2
use BSON and MongoDB in pure Swift
⭐️ 5
🕓 36 weeks ago
macOS
.package(url: "https://github.com/tayloraswift/swift-mongodb.git", from: "v0.7.2")

mongodb
0.14

ci status

swift package index versions swift package index platforms

swift-mongodb is a pure-Swift BSON library and MongoDB driver. All of the constituent products in this package are Foundation-free.

getting started

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)

//  ...

external dependencies

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:

  1. swift-grammar

    Rationale: this package provides the TraceableErrors module which the driver uses to provide rich diagnostics. The driver does not depend on any parser targets.

  2. swift-hash

    Rationale: this package implements cryptographic algorithms the driver uses to complete authentication with mongod/mongos servers.

Other packages:

  1. apple/swift-atomics

    Rationale: this package provides atomic types that improve the performance of the driver’s various concurrent data structures.

  2. apple/swift-collections

    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.

  3. apple/swift-nio

    Rationale: networking.

  4. apple/swift-nio-ssl

    Rationale: networking.

Note: This library depends on the NIOSSL product from swift-nio-ssl, which imports Foundation on Apple platforms only. NIOSSL is Foundation-free on all other platforms.

toolchain requirement

This package requires swift 5.10 or greater.

acknowledgements

This library originally started out as a re-write of Orlandos’s MongoKitten; accordingly the MongoDriver module retains MongoKitten’s original MIT-license.

The official MongoDB C driver also served as prior art for this module.

license

The MongoDriver module is MIT-licensed.

The other modules are available under the MPL 2.0 license. This license was chosen as an organizational default, and is not ideological. Please reach out if you have a use-case that requires a more-permissive license!

GitHub

link
Stars: 5
Last commit: Yesterday
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Release Notes

0.3.0
42 weeks ago
  • greatly simplifies the BSON encoding protocol hierarchy:

    • BSONWeakEncodable no longer exists, and has been folded into BSONEncodable
    • MongoExpressionEncodable no longer exists; instead the expression operator API has been renamed from init to expr to aid typechecking without the need for a parallel encoding protocol
    • Mongo.ExpressionList and its encoder no longer exist
  • adds a protocol MongoExpressionVariable which provides useful API for types modeling expression variables (e.g. $$self)

  • adds a few missing expression operators

  • renamed MongoFieldPathEncodable to MongoKeyPathEncodable

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics