Scope

public final class Scope

A Scope represents a scope or namespace of the collections.

The scope implicitly exists when there is at least one collection created under the scope. The default scope is exceptional in that it will always exists even there are no collections under it.

Scope Lifespan A Scope object remain valid until either the database is closed or the scope itself is invalidated as all collections in the scope have been deleted.

  • The default scope name constant

    Declaration

    Swift

    public static let defaultScopeName: String
  • Scope’s name

    Declaration

    Swift

    public var name: String { get }
  • Collection’s database

    Declaration

    Swift

    public let database: Database

Collections

  • Get all collections in the scope.

    Declaration

    Swift

    public func collections() throws -> [Collection]
  • Get a collection in the scope by name. If the collection doesn’t exist, a nil value will be returned.

    Throws

    An error on when database object is not available.

    Declaration

    Swift

    public func collection(name: String) throws -> Collection?

    Parameters

    name

    Collection name as String.

    Return Value

    Collection object or nil if it doesn’t exist.