PropertyQueryCondition

public class PropertyQueryCondition<E: EntityInspectable & __EntityRelatable, T: EntityPropertyTypeConvertible>:
    QueryCondition<E>
where E == E.EntityBindingType.EntityType

Representation of comparison expression conditions of a Query.

All operators that target entity properties will produce this:

personBox.query { Person.age > 21 }

You can apply a short name (called alias, see PropertyAlias) to later identify specific expressions using the .= operator. This is useful to change the values. The example above with an alias would read:

let query = try personBox.query { "AgeRestriction" .= Person.age > 21 }.build()
// Change the condition to `Person.age > 18`
query.setParameter("AgeRestriction", to: 18)

You can form conditions and use them later, like:

 let alcoholRestriction: QueryCondition<Person> =
         "MinAge" .= Person.age > 21
         && "MaxAge" .= Person.age < 80
 // ...
 let alcoholAllowedQuery = try personBox.query {
     return alcoholRestriction
         || (Person.firstName == "Johnny" && Person.lastName == "Walker")
 }.build()
 try alcoholAllowedQuery.setParameter("MinAge", to: 18)
  • Entity type that contains the property this query condition is describing.

    Declaration

    Swift

    public typealias EntityType = E
  • Supported property value query condition this is describing.

    Declaration

    Swift

    public typealias ValueType = T