SelectTerm
public enum SelectTerm<O> : ExpressibleByStringLiteral, Hashable where O : DynamicObject
extension SelectTerm: CustomDebugStringConvertible, CoreStoreDebugStringConvertible
The SelectTerm is passed to the Select clause to indicate the attributes/aggregate keys to be queried.
-
Provides a
SelectTermto aSelectclause for querying an entity attribute. A shorter way to do the same is to assign from the string keypath directly:let fullName = dataStack.queryValue( From<MyPersonEntity>(), Select<String>(.attribute("fullName")), Where("employeeID", isEqualTo: 1111) )is equivalent to:
let fullName = dataStack.queryValue( From<MyPersonEntity>(), Select<String>("fullName"), Where("employeeID", isEqualTo: 1111) )Declaration
Swift
public static func attribute(_ keyPath: KeyPathString) -> SelectTerm<O>Parameters
keyPaththe attribute name
Return Value
a
SelectTermto aSelectclause for querying an entity attribute -
Provides a
SelectTermto aSelectclause for querying the average value of an attribute.let averageAge = dataStack.queryValue( From<MyPersonEntity>(), Select<Int>(.average("age")) )Declaration
Swift
public static func average(_ keyPath: KeyPathString, as alias: KeyPathString? = nil) -> SelectTerm<O>Parameters
keyPaththe attribute name
aliasthe dictionary key to use to access the result. Ignored when the query return value is not an
NSDictionary. Ifnil, the default key “average()” is used Return Value
a
SelectTermto aSelectclause for querying the average value of an attribute -
Provides a
SelectTermto aSelectclause for a count query.let numberOfEmployees = dataStack.queryValue( From<MyPersonEntity>(), Select<Int>(.count("employeeID")) )Declaration
Swift
public static func count(_ keyPath: KeyPathString, as alias: KeyPathString? = nil) -> SelectTerm<O>Parameters
keyPaththe attribute name
aliasthe dictionary key to use to access the result. Ignored when the query return value is not an
NSDictionary. Ifnil, the default key “count()” is used Return Value
a
SelectTermto aSelectclause for a count query -
Provides a
SelectTermto aSelectclause for querying the maximum value for an attribute.let maximumAge = dataStack.queryValue( From<MyPersonEntity>(), Select<Int>(.maximum("age")) )Declaration
Swift
public static func maximum(_ keyPath: KeyPathString, as alias: KeyPathString? = nil) -> SelectTerm<O>Parameters
keyPaththe attribute name
aliasthe dictionary key to use to access the result. Ignored when the query return value is not an
NSDictionary. Ifnil, the default key “max()” is used Return Value
a
SelectTermto aSelectclause for querying the maximum value for an attribute -
Provides a
SelectTermto aSelectclause for querying the minimum value for an attribute.let minimumAge = dataStack.queryValue( From<MyPersonEntity>(), Select<Int>(.minimum("age")) )Declaration
Swift
public static func minimum(_ keyPath: KeyPathString, as alias: KeyPathString? = nil) -> SelectTerm<O>Parameters
keyPaththe attribute name
aliasthe dictionary key to use to access the result. Ignored when the query return value is not an
NSDictionary. Ifnil, the default key “min()” is used Return Value
a
SelectTermto aSelectclause for querying the minimum value for an attribute -
Provides a
SelectTermto aSelectclause for querying the sum value for an attribute.let totalAge = dataStack.queryValue( From<MyPersonEntity>(), Select<Int>(.sum("age")) )Declaration
Swift
public static func sum(_ keyPath: KeyPathString, as alias: KeyPathString? = nil) -> SelectTerm<O>Parameters
keyPaththe attribute name
aliasthe dictionary key to use to access the result. Ignored when the query return value is not an
NSDictionary. Ifnil, the default key “sum()” is used Return Value
a
SelectTermto aSelectclause for querying the sum value for an attribute -
Provides a
SelectTermto aSelectclause for querying theNSManagedObjectID.let objectID = dataStack.queryValue( From<MyPersonEntity>(), Select<NSManagedObjectID>(), Where("employeeID", isEqualTo: 1111) )Declaration
Swift
public static func objectID(as alias: KeyPathString? = nil) -> SelectTerm<O>Parameters
keyPaththe attribute name
aliasthe dictionary key to use to access the result. Ignored when the query return value is not an
NSDictionary. Ifnil, the default key “objecID” is usedReturn Value
a
SelectTermto aSelectclause for querying the sum value for an attribute
-
Declaration
Swift
public init(stringLiteral value: KeyPathString) -
Declaration
Swift
public init(unicodeScalarLiteral value: KeyPathString) -
Declaration
Swift
public init(extendedGraphemeClusterLiteral value: KeyPathString)
-
Declaration
Swift
public static func == (lhs: SelectTerm<O>, rhs: SelectTerm<O>) -> Bool
-
Declaration
Swift
public func hash(into hasher: inout Hasher)
-
Declaration
Swift
public var debugDescription: String { get }
-
Provides a
SelectTermto aSelectclause for querying the average value of an attribute.Declaration
Swift
public static func average<V>(_ keyPath: KeyPath<O, V>, as alias: KeyPathString? = nil) -> SelectTerm<O>Parameters
keyPaththe attribute name
aliasthe dictionary key to use to access the result. Ignored when the query return value is not an
NSDictionary. Ifnil, the default key “average()” is used Return Value
a
SelectTermto aSelectclause for querying the average value of an attribute -
Provides a
SelectTermto aSelectclause for a count query.Declaration
Swift
public static func count<V>(_ keyPath: KeyPath<O, V>, as alias: KeyPathString? = nil) -> SelectTerm<O>Parameters
keyPaththe attribute name
aliasthe dictionary key to use to access the result. Ignored when the query return value is not an
NSDictionary. Ifnil, the default key “count()” is used Return Value
a
SelectTermto aSelectclause for a count query -
Provides a
SelectTermto aSelectclause for querying the maximum value for an attribute.Declaration
Swift
public static func maximum<V>(_ keyPath: KeyPath<O, V>, as alias: KeyPathString? = nil) -> SelectTerm<O>Parameters
keyPaththe attribute name
aliasthe dictionary key to use to access the result. Ignored when the query return value is not an
NSDictionary. Ifnil, the default key “max()” is used Return Value
a
SelectTermto aSelectclause for querying the maximum value for an attribute -
Provides a
SelectTermto aSelectclause for querying the minimum value for an attribute.Declaration
Swift
public static func minimum<V>(_ keyPath: KeyPath<O, V>, as alias: KeyPathString? = nil) -> SelectTerm<O>Parameters
keyPaththe attribute name
aliasthe dictionary key to use to access the result. Ignored when the query return value is not an
NSDictionary. Ifnil, the default key “min()” is used Return Value
a
SelectTermto aSelectclause for querying the minimum value for an attribute -
Provides a
SelectTermto aSelectclause for querying the sum value for an attribute.Declaration
Swift
public static func sum<V>(_ keyPath: KeyPath<O, V>, as alias: KeyPathString? = nil) -> SelectTerm<O>Parameters
keyPaththe attribute name
aliasthe dictionary key to use to access the result. Ignored when the query return value is not an
NSDictionary. Ifnil, the default key “sum()” is used Return Value
a
SelectTermto aSelectclause for querying the sum value for an attribute
-
Provides a
SelectTermto aSelectclause for querying an entity attribute.Declaration
Swift
public static func attribute<K>(_ keyPath: KeyPath<O, K>) -> SelectTerm<O> where O == K.ObjectType, K : AttributeKeyPathStringConvertibleParameters
keyPaththe attribute name
Return Value
a
SelectTermto aSelectclause for querying an entity attribute -
Provides a
SelectTermto aSelectclause for querying the average value of an attribute.Declaration
Swift
public static func average<K>(_ keyPath: KeyPath<O, K>, as alias: KeyPathString? = nil) -> SelectTerm<O> where O == K.ObjectType, K : AttributeKeyPathStringConvertibleParameters
keyPaththe attribute name
aliasthe dictionary key to use to access the result. Ignored when the query return value is not an
NSDictionary. Ifnil, the default key “average()” is used Return Value
a
SelectTermto aSelectclause for querying the average value of an attribute -
Provides a
SelectTermto aSelectclause for a count query.Declaration
Swift
public static func count<K: AttributeKeyPathStringConvertible>(_ keyPath: KeyPath<O, K>, as alias: KeyPathString? = nil) -> SelectTerm<O> where K.ObjectType == OParameters
keyPaththe attribute name
aliasthe dictionary key to use to access the result. Ignored when the query return value is not an
NSDictionary. Ifnil, the default key “count()” is used Return Value
a
SelectTermto aSelectclause for a count query -
Provides a
SelectTermto aSelectclause for querying the maximum value for an attribute.Declaration
Swift
public static func maximum<K: AttributeKeyPathStringConvertible>(_ keyPath: KeyPath<O, K>, as alias: KeyPathString? = nil) -> SelectTerm<O> where K.ObjectType == OParameters
keyPaththe attribute name
aliasthe dictionary key to use to access the result. Ignored when the query return value is not an
NSDictionary. Ifnil, the default key “max()” is used Return Value
a
SelectTermto aSelectclause for querying the maximum value for an attribute -
Provides a
SelectTermto aSelectclause for querying the minimum value for an attribute.Declaration
Swift
public static func minimum<K>(_ keyPath: KeyPath<O, K>, as alias: KeyPathString? = nil) -> SelectTerm<O> where O == K.ObjectType, K : AttributeKeyPathStringConvertibleParameters
keyPaththe attribute name
aliasthe dictionary key to use to access the result. Ignored when the query return value is not an
NSDictionary. Ifnil, the default key “min()” is used Return Value
a
SelectTermto aSelectclause for querying the minimum value for an attribute -
Provides a
SelectTermto aSelectclause for querying the sum value for an attribute.Declaration
Swift
public static func sum<K>(_ keyPath: KeyPath<O, K>, as alias: KeyPathString? = nil) -> SelectTerm<O> where O == K.ObjectType, K : AttributeKeyPathStringConvertibleParameters
keyPaththe attribute name
aliasthe dictionary key to use to access the result. Ignored when the query return value is not an
NSDictionary. Ifnil, the default key “sum()” is used Return Value
a
SelectTermto aSelectclause for querying the sum value for an attribute
View on GitHub
SelectTerm Enumeration Reference