QueryOn
public final class QueryOn<EntryType>: ChainableQuery where EntryType: EntryModellable
A concrete implementation of AbstractQuery which requires that a model class conforming to EntryType
be passed in as a generic parameter.
The content_type
parameter of the query will be set to the contentTypeID
of your EntryType conforming model class. QueryOn<EntryType> are chainable so complex queries can be constructed.
Operations that are only available when querying Entrys on specific content types (i.e. content_type must be set)
are available through this class.
-
The parameters dictionary that are converted to
URLComponents(HTTP parameters/arguments) on the HTTP URL. Useful for debugging.Declaration
Swift
public var parameters: [String: String] = [String: String]() -
Designated initializer for
QueryOn<EntryType>.Declaration
Swift
public init() -
Convenience intializer for creating a QueryOn with a QueryOperation. Example usage:
let query = QueryOn<Cat>(where: "fields.color", .doesNotEqual("gray"))Declaration
Swift
public convenience init(where name: String, _ operation: QueryOperation, for locale: String? = nil)Parameters
nameThe name of the property you are performing the QueryOperation against. For instance,
"sys.id"or"fields.yourFieldName"operationThe QueryOperation.
localeAn optional locale argument to return localized results. If unspecified, the locale originally set on the
Clientinstance is used. -
Instance method for appending more QueryOperation’s to further filter results on the API. Example usage:
let query = QueryOn<Cat>(where: "fields.color", .doesNotEqual("gray")) // Mutate the query further. query.where("fields.lives", .equals("9"))Declaration
Swift
public func `where`(_ name: String, _ operation: QueryOperation, for locale: String? = nil)Parameters
nameThe name of the property you are performing the QueryOperation against. For instance,
"sys.id" orfields.yourFieldName
`operationthe QueryOperation
localeAn optional locale argument to return localized results. If unspecified, the locale originally set on the
Clientinstance is used. -
Convenience initalizer for performing searches where Linked objects at the specified linking field match the filtering query. For instance, if you want to query all Entry’s of type
cat
where cat’s linked via thebestFriend
field have names that matchHappy Cat
the code would look like the following:let filterQuery = FilterQuery<Cat>(where: "fields.name", .matches("Happy Cat")) let query = QueryOn<Cat>(whereLinkAt: "bestFriend", matches: filterQuery) client.fetchMappedEntries(with: query).observable.then { catsWithHappyCatAsBestFriendResponse in let catsWithHappyCatAsBestFriend = catsWithHappyCatAsBestFriendResponse.items // Do stuff with catsWithHappyCatAsBestFriend }Declaration
Swift
public convenience init<LinkType>(whereLinkAt fieldNameForLink: String, matches filterQuery: FilterQuery<LinkType>? = nil, for locale: String? = nil) where LinkType: EntryModellableParameters
fieldNameForLinkThe name of the property which contains a link to another Entry.
filterQueryThe optional filter query applied to the linked objects which are being searched.
localeAn optional locale argument to return localized results. If unspecified, the locale originally set on the
Clientinstance is used.
View on GitHub
QueryOn Class Reference