ScopesTreeView

public struct ScopesTreeView

A view on the scopes tree defined by row adapters.

For example:

// Define a tree of nested scopes
let adapter = ScopeAdapter([
    "foo": RangeRowAdapter(0..<1),
    "bar": RangeRowAdapter(1..<2).addingScopes([
        "baz" : RangeRowAdapter(2..<3)])])

// Fetch
let sql = "SELECT 1 AS foo, 2 AS bar, 3 AS baz"
let row = try Row.fetchOne(db, sql, adapter: adapter)!

row.scopesTree.names  // ["foo", "bar", "baz"]

row.scopesTree["foo"] // [foo:1]
row.scopesTree["bar"] // [bar:2]
row.scopesTree["baz"] // [baz:3]
  • The scopes defined on this row, recursively.

    Declaration

    Swift

    public var names: Set<String> { get }
  • Returns the row associated with the given scope, by performing a breadth-first search in this row’s scopes and the scopes of its scoped rows, recursively.

    Declaration

    Swift

    public subscript(name: String) -> Row? { get }