Database

public final class Database

A Mongo Database. Cannot be publically initialized. But you can get a database object by subscripting Server with a String as the database name

  • The Server that this Database is a part of

    Declaration

    Swift

    public let server: Server
  • The database’s name

    Declaration

    Swift

    public let name: String
  • Sets or gets the default write concern at the database level

    Declaration

    Swift

    public var writeConcern: WriteConcern?
  • Sets or gets the default read concern at the database level

    Declaration

    Swift

    public var readConcern: ReadConcern?
  • Sets or gets the default collation at the database level

    Declaration

    Swift

    public var collation: Collation?
  • Initialise this database object

    Declaration

    Swift

    public init(named name: String, atServer server: Server)
  • Initializes this Database with a connection String.

    Requires a path with a database name

    Declaration

    Swift

    public init(_ url: String, maxConnectionsPerServer maxConnections: Int = 100) throws
  • Creates a GridFS collection in this database

    Declaration

    Swift

    public func makeGridFS(named name: String = "fs") throws -> GridFS
  • Get a Collection by providing a collection name as a String

    Declaration

    Swift

    public subscript (collection: String) -> Collection

    Return Value

    The requested collection in this database

  • Executes a command Document on this database using a query message

    Declaration

    Swift

    public func execute(dbCommand document: Document, until timeout: TimeInterval = 0, writing: Bool = true) throws -> [Document]

    Return Value

    A Message containing the response

  • A debugging string

    Declaration

    Swift

    public var description: String
  • Iterates over all collections in this database

    Declaration

    Swift

    public func makeIterator() -> AnyIterator<Collection>