Contents

EntityQueryProperty

An object that provides the supported comparators you use to describe the different ways users can query against a property of an app entity.

Declaration

final class EntityQueryProperty<Entity, Subject, Property, PropertyType, ComparatorMappingType> where Entity : AppEntity, Subject : AppEntity, Property : EntityProperty<PropertyType>, PropertyType : _IntentValue, PropertyType : Sendable

Overview

Entity query properties are defined by by providing a KeyPath to an AppEntity property in your data model that this property applies to and then specify the set of supported EntityQueryComparators for this property.

EntityQueryProperty allows you to define more than one EntityQueryComparator with functionality beyond strict equality. The set of comparators available depends on the underlying property type. For example, an Equatable property type will allow for EqualToComparator and NotEqualToComparator comparators while a Comparable property type will add support for GreaterThanComparator, GreaterThanOrEqualToComparator, LessThanComparator, and LessThanOrEqualToComparator comparators. See Comparator for more details on available comparators.

An EntityQueryProperty doesn’t necessarily need to apply to a property of its parent Query Entity.

Consider the scenario where you have an application containing Photo and Album entities, and you want to support querying photos by the name of their containing album. Within a EntityPropertyQuery in which Entity is Photo, you can define a EntityQueryProperty mapping to a name property of the Album entity, as long as you supply a closure for entityProvider that contains the logic to get from a Photo entity to an Album entity.

See init(_:entityProvider:comparators:) for details.

Topics

Creating queryable properties

See Also

Property-matched queries