KeySelector
public struct KeySelector
This type provides a selector for specifying keys in a range read.
Key ranges are specified relative to an anchor key, and allow finding the first key greater than or less than that key. They also allow specifying offsets to say that we should skip a certain number of keys forward or backward before finding the real key for the range.
-
This initializer creates a key selector from the constituent parts, as understood by the FoundationDB C API.
Declaration
Swift
public init(anchor: DatabaseValue, orEqual: Int, offset: Int)
Parameters
anchor
The reference point for the selector.
orEqual
Whether we should allow the selector to match the anchor. For positive offsets, 1 means false and 0 means true. For zero and negative offsets, 1 means true and 0 means false.
offset
The number of steps we should skip forward or backward from the first matching key to find the returned key. This also encodes the direction of the comparison. A positive offset means a greater than comparison, skipping forward by
offset - 1
. A zero or negative offset means a less than comparison, skipping backward by-1 * offset
. -
This initializer creates a selector for finding keys greater than or equal to a given key.
Declaration
Swift
public init(greaterThan value: DatabaseValue, orEqual: Bool = false, offset: Int = 0)
Parameters
value
The anchor key.
orEqual
Whether we should include the anchor key.
offset
The number of keys that we should skip forward.
-
This initializer creates a selector for finding keys less than or equal to a given key.
Declaration
Swift
public init(lessThan value: DatabaseValue, orEqual: Bool = false, offset: Int = 0)
Parameters
value
The anchor key.
orEqual
Whether we should include the anchor key.
offset
The number of keys that we should skip backward.