Contents

Query(filter:sort:order:animation:)

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

Declaration

@attached(accessor) @attached(peer, names: prefixed(`_`)) macro Query<Value, Element>(filter: Predicate<Element>? = nil, sort keyPath: KeyPath<Element, Value?>, order: SortOrder = .forward, animation: Animation) 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 optional attribute to sort by.

  • order:

    The order of the sort.

  • animation:

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

See Also

Predicate-based queries