Contents

Query(filter:sort:order:transaction:)

Fetches a subset of the attached model type, in a specific order, by sorting on a nonoptional attribute.

Declaration

@attached(accessor) @attached(peer, names: prefixed(`_`)) macro Query<Value, Element>(filter: Predicate<Element>? = nil, sort keyPath: KeyPath<Element, Value>, order: SortOrder = .forward, transaction: Transaction? = nil) where Value : Comparable, Element : PersistentModel

Parameters

  • filter:

    The logical condition the query uses to determine if it returns a specific model instance.

  • keyPath:

    The keypath of the nonoptional attribute to sort by.

  • order:

    The order of the sort.

  • transaction:

    The transaction to use when updates to the fetched models trigger user interface changes.

See Also

Predicate-based queries