Relation
public protocol Relation : PlaygroundMonospace
A protocol defining a relation, which is conceptually a set of Rows, all of which have
the same scheme.
-
The relation’s scheme.
Declaration
Swift
var scheme: Scheme { get } -
The debug name for the
Relation, which can be handy for identifying them in debug dumps.Declaration
Swift
var debugName: String? { get set }
-
project(_:)Default implementationUndocumented
Default Implementation
Undocumented
Undocumented
Declaration
Swift
func project(_ scheme: Scheme) -> Relation -
project(dropping:)Default implementationUndocumented
Default Implementation
Returns a projection of this Relation that includes only those attributes that appear in this Relation’s scheme but not in the given scheme.
Declaration
Swift
func project(dropping scheme: Scheme) -> Relation -
Undocumented
Declaration
Swift
func project(_ attribute: Attribute) -> Relation -
select(_:)Default implementationPerform a select operation with a query defined by the contents of a
Row. The resulting query is equivalent to ANDing together an equality expression for each attribute in the row, requiring it to be equal to that value in the row.Default Implementation
Undocumented
Undocumented
Declaration
Swift
func select(_ rowToFind: Row) -> Relation -
Perform a select operation with the given query.
Declaration
Swift
func select(_ query: SelectExpression) -> Relation -
renameAttributes(_:)Default implementation -
renamePrime()Default implementationUndocumented
Default Implementation
Undocumented
Declaration
Swift
func renamePrime() -> Relation -
projectRenamed(_:)Default implementation -
union(_:)Default implementationReturn a new
Relationwhich represents the union of thisRelationand another one.Default Implementation
Declaration
Swift
func union(_ other: Relation) -> Relation -
intersection(_:)Default implementationReturn a new
Relationwhich represents the intersection of thisRelationand another one.Default Implementation
Declaration
Swift
func intersection(_ other: Relation) -> Relation -
difference(_:)Default implementationReturn a new
Relationwhich represents the difference of thisRelationand another one.Default Implementation
Declaration
Swift
func difference(_ other: Relation) -> Relation -
join(_:)Default implementationReturn a new
Relationwhich represents the join of thisRelationand another one. This is equivalent to anequijoinwhere the matches are equal to the intersection of the two schemes.Default Implementation
Declaration
Swift
func join(_ other: Relation) -> Relation -
equijoin(_:matching:)Default implementationReturn a new
Relationwhich represents the join of thisRelationand another one, matching the values for the attributes given in thematchingparameter.Default Implementation
-
thetajoin(_:query:)Default implementationUndocumented
Default Implementation
Undocumented
Declaration
Swift
func thetajoin(_ other: Relation, query: SelectExpression) -> Relation -
split(_:)Default implementationUndocumented
Default Implementation
Undocumented
Declaration
Swift
func split(_ query: SelectExpression) -> (Relation, Relation) -
divide(_:)Default implementationUndocumented
Default Implementation
Undocumented
Declaration
Swift
func divide(_ other: Relation) -> Relation
-
leftOuterJoin(_:)Default implementationUndocumented
Default Implementation
Undocumented
Declaration
Swift
func leftOuterJoin(_ other: Relation) -> Relation
-
min(_:)Default implementationUndocumented
Default Implementation
Undocumented
Declaration
Swift
func min(_ attribute: Attribute) -> Relation -
max(_:)Default implementationUndocumented
Default Implementation
Undocumented
Declaration
Swift
func max(_ attribute: Attribute) -> Relation -
count()Default implementationUndocumented
Default Implementation
Undocumented
Declaration
Swift
func count() -> Relation
-
otherwise(_:)Default implementationReturn a new
Relationthat resolves to this Relation when it is non-empty, otherwise resolves to the other Relation.Default Implementation
Declaration
Swift
func otherwise(_ other: Relation) -> Relation -
unique(_:matching:)Default implementationReturn a new
Relationthat resolves to this Relation when there is a unique value for the given attribute that is the same asmatching, otherwise resolves to an empty Relation.Default Implementation
Declaration
Swift
func unique(_ attribute: Attribute, matching: RelationValue) -> Relation
-
withUpdate(_:newValues:)Default implementationReturn a new
Relationwhich represents thisRelationwith the given updates applied to all rows that match the query.Default Implementation
Declaration
Swift
func withUpdate(_ query: SelectExpression, newValues: Row) -> Relation -
withUpdate(_:)Default implementationReturn a new
Relationwhich represents thisRelationwith the given updates applied to all rows.Default Implementation
Declaration
Swift
func withUpdate(_ newValues: Row) -> Relation
-
addAsyncObserver(_:)Extension methodUndocumented
Declaration
Swift
func addAsyncObserver(_ observer: AsyncRelationChangeObserver) -> AsyncManager.ObservationRemover -
addAsyncObserver(_:)Extension methodUndocumented
Declaration
Swift
func addAsyncObserver(_ observer: AsyncRelationChangeCoalescedObserver) -> AsyncManager.ObservationRemover
-
addAsyncObserver(_:)Extension methodUndocumented
Declaration
Swift
func addAsyncObserver(_ observer: AsyncRelationContentObserver) -> AsyncManager.ObservationRemover -
addAsyncObserver(_:postprocessor:)Extension methodIf desired, this method can be used to supply a postprocessor function which runs in the background after the rows are accumulated but before results are sent to the observer. This postprocessor can, for example, sort the rows and produce an array which is then passed to the observer.
Declaration
Swift
func addAsyncObserver<T: AsyncRelationContentCoalescedObserver>(_ observer: T, postprocessor: @escaping (Set<Row>) -> T.PostprocessingOutput) -> AsyncManager.ObservationRemover -
addAsyncObserver(_:)Extension methodThis method may be used when the observer just wants a raw set of rows to be delivered, without any postprocessing.
Declaration
Swift
func addAsyncObserver<T>(_ observer: T) -> AsyncManager.ObservationRemover where T : AsyncRelationContentCoalescedObserver, T.PostprocessingOutput == Set<Row>
-
asyncUpdate(_:newValues:)Extension methodUndocumented
Declaration
Swift
func asyncUpdate(_ query: SelectExpression, newValues: Row)
-
cache(upTo:)Extension methodReturn a new CachingRelation that caches
selfup to the specified limitDeclaration
Swift
public func cache(upTo: Int) -> CachingRelation
-
mutableSelect(_:)Extension methodUndocumented
Declaration
Swift
public func mutableSelect(_ expression: SelectExpression) -> MutableSelectRelation
-
setDebugName(_:)Extension methodSet the debug name and return self, for convenient chaining. Value-type relations return a new one rather than mutating in place.
Declaration
Swift
public func setDebugName(_ name: String) -> Self
-
asyncBulkRows(_:)Extension methodFetch rows and invoke a callback as they come in. Each call is passed one or more rows, or an error. If no error occurs, the sequence of calls is terminated by a final call which passes zero rows.
-
asyncBulkRows(_:)Extension methodFetch rows and invoke a callback as they come in. Each call is passed one or more rows, or an error. If no error occurs, the sequence of calls is terminated by a final call which passes zero rows.
-
asyncAllRows(_:)Extension method -
asyncAllRows(_:)Extension method -
asyncAllRows(postprocessor:completion:)Extension method
-
descriptionExtension methodDeclaration
Swift
public var description: String { get }
-
recursiveSelect(initialQueryAttr:initialQueryValue:initialValue:rowCallback:filterCallback:completionCallback:)Extension methodPerform a recursive
selectquery on this relation. This is modeled aftercascadingDelete.Declaration
Swift
public func recursiveSelect<T>( initialQueryAttr: Attribute, initialQueryValue: RelationValue, initialValue: T, rowCallback: @escaping (RelationObject, Row, T) -> Result<(T, [RecursiveQuery]), RelationError>, filterCallback: @escaping (T, Set<RecursiveQuery>) -> Set<RecursiveQuery>, completionCallback: @escaping (Result<T, RelationError>) -> Void)
-
arrayProperty(idAttr:orderAttr:descending:tag:)Extension methodReturns an ArrayProperty that gets its data from this relation.
Declaration
Swift
public func arrayProperty(idAttr: Attribute, orderAttr: Attribute, descending: Bool = false, tag: AnyObject? = nil) -> ArrayProperty<RowArrayElement>
-
emptyExtension methodReturns a Signal that delivers true when the set of rows is empty.
Declaration
Swift
public var empty: Signal<Bool> { get } -
nonEmptyExtension methodReturns a Signal that delivers true when the set of rows is non-empty.
Declaration
Swift
public var nonEmpty: Signal<Bool> { get } -
allValuesForSingleAttribute(_:)Extension methodReturns a Signal, sourced from this relation, that delivers all values for the single attribute.
Declaration
Swift
public func allValuesForSingleAttribute<V: Hashable>(_ transform: @escaping (RelationValue) -> V?) -> Signal<Set<V>> -
allRelationValues()Extension methodReturns a Signal, sourced from this relation, that delivers a set of all RelationValues for the single attribute.
Declaration
Swift
public func allRelationValues() -> Signal<Set<RelationValue>> -
allValues(_:)Extension method -
allStrings()Extension methodReturns a Signal, sourced from this relation, that delivers a set of all strings for the single attribute.
Declaration
Swift
public func allStrings() -> Signal<Set<String>> -
oneRow()Extension method -
valueFromOneRow(_:)Extension method -
valueFromOneRow(_:)Extension method -
valueFromOneRow(_:orDefault:)Extension method -
valueFromOneRow(_:orDefault:)Extension method -
oneValueOrNil(_:)Extension methodReturns a Signal, sourced from this relation, that delivers a single transformed value if there is exactly one row, otherwise delivers nil.
Declaration
Swift
public func oneValueOrNil<V>(_ transform: @escaping (RelationValue) -> V?) -> Signal<V?> -
oneValueOrNil(_:)Extension methodReturns a Signal, sourced from this relation, that delivers a single transformed value if there is exactly one row, otherwise delivers nil.
Declaration
Swift
public func oneValueOrNil<V: Equatable>(_ transform: @escaping (RelationValue) -> V?) -> Signal<V?> -
oneValue(_:orDefault:initialValue:)Extension methodReturns a Signal, sourced from this relation, that delivers a single transformed value if there is exactly one row, otherwise delivers the given default value.
Declaration
Swift
public func oneValue<V>(_ transform: @escaping (RelationValue) -> V?, orDefault defaultValue: V, initialValue: V? = nil) -> Signal<V> -
oneValue(_:orDefault:initialValue:)Extension methodReturns a Signal, sourced from this relation, that delivers a single transformed value if there is exactly one row, otherwise delivers the given default value.
Declaration
Swift
public func oneValue<V: Equatable>(_ transform: @escaping (RelationValue) -> V?, orDefault defaultValue: V, initialValue: V? = nil) -> Signal<V> -
oneRelationValueOrNil()Extension methodReturns a Signal, sourced from this relation, that delivers a single RelationValue if there is exactly one row, otherwise delivers nil.
Declaration
Swift
public func oneRelationValueOrNil() -> Signal<RelationValue?> -
oneStringOrNil(initialValue:)Extension methodReturns a Signal, sourced from this relation, that delivers a single string value if there is exactly one row, otherwise delivers nil.
Declaration
Swift
public func oneStringOrNil(initialValue: String?? = nil) -> Signal<String?> -
oneString(initialValue:)Extension methodReturns a Signal, sourced from this relation, that delivers a single string value if there is exactly one row, otherwise delivers an empty string.
Declaration
Swift
public func oneString(initialValue: String? = nil) -> Signal<String> -
oneIntegerOrNil(initialValue:)Extension methodReturns a Signal, sourced from this relation, that delivers a single integer value if there is exactly one row, otherwise delivers nil.
Declaration
Swift
public func oneIntegerOrNil(initialValue: Int64?? = nil) -> Signal<Int64?> -
oneInteger(initialValue:)Extension methodReturns a Signal, sourced from this relation, that delivers a single integer value if there is exactly one row, otherwise delivers zero.
Declaration
Swift
public func oneInteger(initialValue: Int64? = nil) -> Signal<Int64> -
oneDoubleOrNil(initialValue:)Extension methodReturns a Signal, sourced from this relation, that delivers a single double value if there is exactly one row, otherwise delivers nil.
Declaration
Swift
public func oneDoubleOrNil(initialValue: Double?? = nil) -> Signal<Double?> -
oneDouble(initialValue:)Extension methodReturns a Signal, sourced from this relation, that delivers a single double value if there is exactly one row, otherwise delivers zero.
Declaration
Swift
public func oneDouble(initialValue: Double? = nil) -> Signal<Double> -
oneBoolOrNil(initialValue:)Extension methodReturns a Signal, sourced from this relation, that delivers a single boolean value if there is exactly one row, otherwise delivers nil.
Declaration
Swift
public func oneBoolOrNil(initialValue: Bool?? = nil) -> Signal<Bool?> -
oneBool(initialValue:)Extension methodReturns a Signal, sourced from this relation, that delivers a single boolean value if there is exactly one row, otherwise delivers false.
Declaration
Swift
public func oneBool(initialValue: Bool? = nil) -> Signal<Bool> -
oneBlobOrNil(initialValue:)Extension methodReturns a Signal, sourced from this relation, that delivers a single blob value if there is exactly one row, otherwise delivers nil.
Declaration
Swift
public func oneBlobOrNil(initialValue: [UInt8]?? = nil) -> Signal<[UInt8]?> -
oneBlob(initialValue:)Extension methodReturns a Signal, sourced from this relation, that delivers a single blob value if there is exactly one row, otherwise delivers an empty array.
Declaration
Swift
public func oneBlob(initialValue: [UInt8]? = nil) -> Signal<[UInt8]> -
commonValue(_:)Extension methodReturns a Signal, sourced from this relation, that delivers a CommonValue that indicates whether there are zero, one, or multiple rows.
Declaration
Swift
public func commonValue<V>(_ transform: @escaping (RelationValue) -> V?) -> Signal<CommonValue<V>>
-
extractAllValuesForSingleAttribute(from:_:)Extension methodReturns a set of all values for the single attribute, built from one transformed value for each non-error row in the given set.
Declaration
Swift
public func extractAllValuesForSingleAttribute<V: Hashable>(from rows: AnyIterator<Row>, _ transform: @escaping (RelationValue) -> V?) -> Set<V> -
extractAllValuesForSingleAttribute(_:)Extension methodReturns a set of all values for the single attribute, built from one transformed value for each non-error row in the relation.
Declaration
Swift
public func extractAllValuesForSingleAttribute<V: Hashable>(_ transform: @escaping (RelationValue) -> V?) -> Set<V> -
extractAllRelationValues(from:)Extension methodReturns a set of all RelationValues for the single attribute, built from one RelationValue for each non-error row in the given set.
Declaration
Swift
public func extractAllRelationValues(from rows: AnyIterator<Row>) -> Set<RelationValue> -
extractAllRelationValues()Extension methodReturns a set of all RelationValues for the single attribute in the relation.
Declaration
Swift
public func extractAllRelationValues() -> Set<RelationValue> -
extractAllValues(from:_:)Extension method -
extractAllValues(_:)Extension methodReturns a set of all values, built from one transformed value for each non-error row in the relation.
Declaration
Swift
public func extractAllValues<V: Hashable>(_ transform: @escaping (Row) -> V?) -> Set<V>
-
extractOneRow(_:)Extension method -
extractOneRow()Extension methodReturns a single row if there is exactly one row in the relation, otherwise returns nil.
Declaration
Swift
public func extractOneRow() -> Row?
-
extractValueFromOneRow(_:_:)Extension method -
extractValueFromOneRow(_:)Extension methodReturns a single transformed value if there is exactly one row in the relation, otherwise returns nil.
Declaration
Swift
public func extractValueFromOneRow<V>(_ transform: @escaping (Row) -> V?) -> V? -
extractValueFromOneRow(_:_:orDefault:)Extension method -
extractValueFromOneRow(_:orDefault:)Extension methodReturns a single transformed value if there is exactly one row in the relation, otherwise returns the given default value.
Declaration
Swift
public func extractValueFromOneRow<V>(_ transform: @escaping (Row) -> V?, orDefault defaultValue: V) -> V -
extractOneValueOrNil(from:_:)Extension methodReturns a single transformed value if there is exactly one row in the given set, otherwise returns nil.
Declaration
Swift
public func extractOneValueOrNil<V>(from rows: AnyIterator<Row>, _ transform: @escaping (RelationValue) -> V?) -> V? -
extractOneValueOrNil(_:)Extension methodReturns a single transformed value if there is exactly one row in the relation, otherwise returns nil.
Declaration
Swift
public func extractOneValueOrNil<V>(_ transform: @escaping (RelationValue) -> V?) -> V? -
extractOneValue(from:_:orDefault:)Extension methodReturns a single transformed value if there is exactly one row in the given set, otherwise returns the given default value.
Declaration
Swift
public func extractOneValue<V>(from rows: AnyIterator<Row>, _ transform: @escaping (RelationValue) -> V?, orDefault defaultValue: V) -> V -
extractOneValue(_:orDefault:)Extension methodReturns a single transformed value if there is exactly one row in the relation, otherwise returns the given default value.
Declaration
Swift
public func extractOneValue<V>(_ transform: @escaping (RelationValue) -> V?, orDefault defaultValue: V) -> V -
extractOneRelationValueOrNil(from:)Extension methodReturns a single RelationValue if there is exactly one row in the given set, otherwise returns nil.
Declaration
Swift
public func extractOneRelationValueOrNil(from rows: AnyIterator<Row>) -> RelationValue? -
extractOneRelationValueOrNil()Extension methodReturns a single RelationValue if there is exactly one row in the relation, otherwise returns nil.
Declaration
Swift
public func extractOneRelationValueOrNil() -> RelationValue?
-
extractOneStringOrNil(from:)Extension methodReturns a a single string value if there is exactly one row in the given set, otherwise returns nil.
Declaration
Swift
public func extractOneStringOrNil(from rows: AnyIterator<Row>) -> String? -
extractOneStringOrNil()Extension methodReturns a single string value if there is exactly one row in the relation, otherwise returns nil.
Declaration
Swift
public func extractOneStringOrNil() -> String? -
extractOneString(from:)Extension methodReturns a single string value if there is exactly one row in the given set, otherwise returns an empty string.
Declaration
Swift
public func extractOneString(from rows: AnyIterator<Row>) -> String -
extractOneString()Extension methodReturns a single string value if there is exactly one row in the relation, otherwise returns an empty string.
Declaration
Swift
public func extractOneString() -> String
-
extractOneIntegerOrNil(from:)Extension methodReturns a single integer value if there is exactly one row in the given set, otherwise returns nil.
Declaration
Swift
public func extractOneIntegerOrNil(from rows: AnyIterator<Row>) -> Int64? -
extractOneIntegerOrNil()Extension methodReturns a single integer value if there is exactly one row in the relation, otherwise returns nil.
Declaration
Swift
public func extractOneIntegerOrNil() -> Int64? -
extractOneInteger(from:)Extension methodReturns a single integer value if there is exactly one row in the given set, otherwise returns zero.
Declaration
Swift
public func extractOneInteger(from rows: AnyIterator<Row>) -> Int64 -
extractOneInteger()Extension methodReturns a single integer value if there is exactly one row in the relation, otherwise returns zero.
Declaration
Swift
public func extractOneInteger() -> Int64
-
extractOneDoubleOrNil(from:)Extension methodReturns a single double value if there is exactly one row in the given set, otherwise returns nil.
Declaration
Swift
public func extractOneDoubleOrNil(from rows: AnyIterator<Row>) -> Double? -
extractOneDoubleOrNil()Extension methodReturns a single double value if there is exactly one row in the relation, otherwise returns nil.
Declaration
Swift
public func extractOneDoubleOrNil() -> Double? -
extractOneDouble(from:)Extension methodReturns a single double value if there is exactly one row in the given set, otherwise returns zero.
Declaration
Swift
public func extractOneDouble(from rows: AnyIterator<Row>) -> Double -
extractOneDouble()Extension methodReturns a single double value if there is exactly one row in the relation, otherwise returns zero.
Declaration
Swift
public func extractOneDouble() -> Double
-
extractOneBoolOrNil(from:)Extension methodReturns a single boolean value if there is exactly one row in the given set, otherwise returns nil.
Declaration
Swift
public func extractOneBoolOrNil(from rows: AnyIterator<Row>) -> Bool? -
extractOneBoolOrNil()Extension methodReturns a single boolean value if there is exactly one row in the relation, otherwise returns nil.
Declaration
Swift
public func extractOneBoolOrNil() -> Bool? -
extractOneBool(from:)Extension methodReturns a single boolean value if there is exactly one row in the given set, otherwise returns false.
Declaration
Swift
public func extractOneBool(from rows: AnyIterator<Row>) -> Bool -
extractOneBool()Extension methodReturns a single boolean value if there is exactly one row in the relation, otherwise returns false.
Declaration
Swift
public func extractOneBool() -> Bool
-
extractOneBlobOrNil(from:)Extension methodReturns a single blob value if there is exactly one row in the given set, otherwise returns nil.
Declaration
Swift
public func extractOneBlobOrNil(from rows: AnyIterator<Row>) -> [UInt8]? -
extractOneBlobOrNil()Extension methodReturns a single blob value if there is exactly one row in the relation, otherwise returns nil.
Declaration
Swift
public func extractOneBlobOrNil() -> [UInt8]? -
extractOneBlob(from:)Extension methodReturns a single blob value if there is exactly one row in the given set, otherwise returns an empty array.
Declaration
Swift
public func extractOneBlob(from rows: AnyIterator<Row>) -> [UInt8] -
extractOneBlob()Extension methodReturns a single blob value if there is exactly one row in the relation, otherwise returns an empty array.
Declaration
Swift
public func extractOneBlob() -> [UInt8]
-
extractCommonValue(from:_:)Extension methodReturns a CommonValue that indicates whether there are zero, one, or multiple rows in the given set.
Declaration
Swift
public func extractCommonValue<V>(from rows: AnyIterator<Row>, _ transform: (RelationValue) -> V?) -> CommonValue<V> where V : Equatable -
extractCommonValue(_:)Extension methodReturns a CommonValue that indicates whether there are zero, one, or multiple rows in the given set.
Declaration
Swift
public func extractCommonValue<V>(_ transform: (RelationValue) -> V?) -> CommonValue<V> where V : Equatable -
okRows()Extension methodMARK: Row iterators Generates all non-error rows in the relation.
Declaration
Swift
public func okRows() -> AnyIterator<Row>
-
asyncUpdateValue(_:)Extension methodPerforms an asynchronous update using a single RelationValue.
Declaration
Swift
public func asyncUpdateValue(_ value: RelationValue) -
asyncUpdateString(_:)Extension methodPerforms an asynchronous update using a single string value.
Declaration
Swift
public func asyncUpdateString(_ value: String) -
asyncUpdateNullableString(_:)Extension methodPerforms an asynchronous update using a single optional string value.
Declaration
Swift
public func asyncUpdateNullableString(_ value: String?) -
asyncUpdateInteger(_:)Extension methodPerforms an asynchronous update using a single integer value.
Declaration
Swift
public func asyncUpdateInteger(_ value: Int64) -
asyncUpdateBoolean(_:)Extension methodPerforms an asynchronous update using a single boolean value (converted to 0 for
falseand 1 fortrue).Declaration
Swift
public func asyncUpdateBoolean(_ value: Bool)
-
signal(initialValue:_:)Extension method -
signal(initialValue:_:)Extension method -
signal(initialValue:_:)Extension method -
signal(initialValue:_:)Extension method
-
treeProperty(idAttr:parentAttr:orderAttr:tag:)Extension methodReturns a TreeProperty that gets its data from this relation.
Declaration
Swift
public func treeProperty(idAttr: Attribute, parentAttr: Attribute, orderAttr: Attribute, tag: AnyObject? = nil) -> TreeProperty<RowTreeNode>
-
undoableOneString(_:_:initialValue:)Extension methodReturns an AsyncReadWriteProperty that delivers a single string value if there is exactly one row in the relation (otherwise an empty string), and updates the relation when a new string value is provided to the property.
Declaration
Swift
public func undoableOneString(_ db: UndoableDatabase, _ action: String, initialValue: String? = nil) -> AsyncReadWriteProperty<String> -
undoableTransformedString(_:_:initialValue:fromString:toString:)Extension methodReturns an AsyncReadWriteProperty that delivers a single value (transformed from a string) and updates the relation with a new string (transformed from a value of type
T) when one is provided to the property.Declaration
Swift
public func undoableTransformedString<T>(_ db: UndoableDatabase, _ action: String, initialValue: String? = nil, fromString: @escaping (String) -> T, toString: @escaping (T) -> String) -> AsyncReadWriteProperty<T>
Relation Protocol Reference