ResultSet

public class ResultSet : ObservableObject

This class wraps a query and its results, and is responsible for loading a the result and possibly applying clienside filtering

  • Object describing the query and postprocessing instructions

    Declaration

    Swift

    var datasource: Datasource
  • Resulting Items

    Declaration

    Swift

    var items: [Item]
  • Nr of items in the resultset

    Declaration

    Swift

    var count: Int
  • Boolean indicating whether the Items in the result are currently being loaded

    Declaration

    Swift

    var isLoading: Bool
  • Computes the type of the data items being requested via the query Returns “mixed” when data items of multiple types can be returned

    Declaration

    Swift

    var determinedType: String? { get }
  • Boolean indicating whether the resultset is a collection of items or a single item

    Declaration

    Swift

    var isList: Bool { get }
  • Get the only item from the resultset if the set has size 1, else return nil. Note that singleton is here in the mathematical sense.

    Declaration

    Swift

    var singletonItem: Item? { get set }
  • Text used to filter queries

    Declaration

    Swift

    var filterText: String? { get set }
  • Undocumented

    Declaration

    Swift

    required init(_ ch: Cache, _ datasource: Datasource)
  • Executes a query given the current QueryOptions, filters the result client side and executes the callback on the resulting Items

    Throws

    empty query error

    Declaration

    Swift

    func load(
        syncWithRemote: Bool = true,
        _ callback: @escaping (_ error: Error?) throws -> Void
    ) throws

    Parameters

    callback

    Callback with params (error: Error, result: [Item]) that is executed on the returned result

  • Force update the items property, recompute the counts and reapply filters

    Declaration

    Swift

    func reload() throws

    Parameters

    result

    the new items

  • Apply client side filter using the FilterText , with a fallback to the server

    Declaration

    Swift

    public func filter()
  • Executes the query again

    Declaration

    Swift

    public func reload(_: ResultSet)
  • Remark

    currently unused

    Todo

    Implement

    Declaration

    Swift

    public func resort(_: Datasource)

    Parameters

    options

  • Mark page with pageIndex as index as loaded

    Declaration

    Swift

    func setPagesLoaded(_ pageIndex: Int)

    Parameters

    pageIndex

    index of the page to mark as loaded