swift-mongodb
is a pure-Swift, Foundation-less BSON library and MongoDB driver.
products
This package vends the following library products:
-
Defines BSON types. Consumers that don’t need to perform any decoding or encoding, or interact with variants (union types) can depend on this product alone.
This module contains a type (
BSON
) of the same name as the module itself, so every declaration in this module is namespaced to that type.Does not re-export
BSONTraversal
. -
BSONDecoding
(BSON
*,BSONUnions
)Vends tools for (performantly) decoding BSON with an emphasis on type-safety and avoiding allocations.
Also vends a fallback
Decoder
interface for consumers migrating fromDecodable
.Re-exports
BSON
, but notBSONUnions
. -
Vends tools for (performantly) encoding BSON with an emphasis on static typing and legibility.
Re-exports
BSON
. -
BSONSchema
(BSONDecoding
*,BSONEncoding
*)Convenience module that re-exports
BSONDecoding
andBSONEncoding
, and defines the typealiasesBSONScheme
andBSONStringScheme
. Contains no code of its own. -
Defines the
AnyBSON
union type, theBSON.TypecastError
type, and provides tools for working with heterogenous/dynamically-typed BSON.Also vends
ExpressibleByArrayLiteral
andExpressibleByDictionaryLiteral
conformances for various BSON types, includingAnyBSON
.Does not re-export
BSON
. -
MongoDB
(MongoDriver
*,MongoSchema
)Vends Swift bindings for MongoDB’s command API, and also implements cursors and managed cursor streams. Most package consumers will depend this module, unless it is possible to depend on one of its constituent dependencies.
Depends on SwiftNIO (indirectly), and re-exports
MongoDriver
. -
MongoDriver
(Mongo
*,MongoWire
,BSONSchema
,SCRAM
,TraceableErrors
,UUID
,SHA2
,NIOCore
,NIOPosix
,NIOSSL
,Atomics
)Implements a MongoDB driver, for communicating with a
mongod
/mongos
server. Handles authentication, sessions, transactions, and command execution, but does not define specific MongoDB commands other than the ones needed to bootstrap a connection.MongoDriver
has the concept of databases, but does not have any awareness of collections, or other high-level database concepts.Depends on SwiftNIO, and re-exports
Mongo
. -
Interface module that defines the
MongoDecodable
andMongoEncodable
protocols, and theMongoScheme
typealias.Consumers that only implement MongoDB schema and do not need to use the MongoDB driver can depend on this product alone.
Does not re-export
BSONSchema
. -
Implements the MongoDB wire protocol, in a generic manner without dependency on SwiftNIO.
This module contains a type (
MongoWire
) of the same name as the module itself, so every declaration in this module is namespaced to that type. -
SCRAM
(Base64
,MessageAuthentication
)Implements SCRAM. The module is intended to be used with MongoDB SCRAM-SHA-256, but is not strongly coupled with any particular flavor of SCRAM.
-
Provides support for error chaining and pretty-printing of errors.
-
Defines the
UUID
type, and an interface for interacting with UUIDs asRandomAccessCollection
s ofUInt8
.
Please avoid depending on SCRAM
, TraceableErrors
, UUID
, and the BSON libraries; they are likely to migrate to a separate repository in the medium-term.
license
The MongoDriver
module was originally a re-write of MongoKitten’s MongoClient
module. Although its fork-ancestor is not really recognizable in the module’s current form, MongoKitten was MIT-licensed, so MongoDriver
is MIT-licensed as well.
The rest of the project is available under the MPL 2.0 license.
acknowledgements
swift-mongodb
started out as a re-write of Orlandos’s MongoKitten; without MongoKitten, swift-mongodb
would not exist.