Classes
The following classes are available globally.
-
A MongoDB Client.
See moreDeclaration
Swift
public class MongoClient
-
See moreBSONDecoder
facilitates the decoding of BSON into semanticDecodable
types.Declaration
Swift
public class BSONDecoder
-
See moreBSONEncoder
facilitates the encoding ofEncodable
values into BSON.Declaration
Swift
public class BSONEncoder
-
The storage backing a MongoSwift
Document
.Declaration
Swift
public class DocumentStorage
-
A MongoDB client session. This class represents a logical session used for ordering sequential operations.
To create a client session, use
startSession
orwithSession
on aMongoClient
.If
causalConsistency
is not set tofalse
when starting a session, read and write operations that use the session will be provided causal consistency guarantees depending on the read and write concerns used. Usingmajority
read and write preferences will provide the full set of guarantees. See https://docs.mongodb.com/manual/core/read-isolation-consistency-recency/#sessions for more details.e.g.
let opts = CollectionOptions(readConcern: ReadConcern(.majority), writeConcern: try WriteConcern(w: .majority)) let collection = database.collection("mycoll", options: opts) try client.withSession { session in try collection.insertOne(["x": 1], session: session) try collection.find(["x": 1], session: session) }
To disable causal consistency, set
causalConsistency
tofalse
in theClientSessionOptions
passed in to eitherwithSession
orstartSession
.See also
Declaration
Swift
public final class ClientSession
-
A MongoDB collection.
See moreDeclaration
Swift
public class MongoCollection<T> where T : Decodable, T : Encodable
-
A class encapsulating a
mongoc_bulk_operation_t
.Declaration
Swift
public class BulkWriteOperation : Operation
-
A MongoDB cursor.
See moreDeclaration
Swift
public class MongoCursor<T> : Sequence, IteratorProtocol where T : Decodable, T : Encodable
-
A MongoDB Database.
See moreDeclaration
Swift
public class MongoDatabase
-
A class to represent a MongoDB read concern.
See moreDeclaration
Swift
public class ReadConcern : Codable
-
A class to represent a MongoDB read preference.
See moreDeclaration
Swift
public final class ReadPreference
-
A class to represent a MongoDB write concern.
See moreDeclaration
Swift
public class WriteConcern : Codable