Query
public class Query : BaseQuery, EntryQueryable
To fetch all or find Entries use Query
.
-
Undocumented
Declaration
Swift
public typealias ResourceType = EntryModel
-
Stack instance for Entry to be fetched
Declaration
Swift
public var stack: Stack
-
URI Parameters
Declaration
Swift
public var parameters: [String : Any]
-
Query Parameters
Declaration
Swift
public var queryParameter: [String : Any]
-
Declaration
Swift
public var cachePolicy: CachePolicy
-
Use this method to do a search on
Entries
which enables searching for entries based on value’s for field key Path.Example usage:
let stack = Contentstack.stack(apiKey: apiKey, deliveryToken: deliveryToken, environment: environment) stack.contentType(uid: contentTypeUid).entry().query() .where(valueAtKey: .title, .equals("Entry Title")) .find { (result: Result<ContentstackResponse<EntryModel>, Error>, response: ResponseType) in switch result { case .success(let contentstackResponse): // Contentstack response with AssetModel array in items. case .failure(let error): //Error Message } }
Declaration
Swift
public func `where`(valueAtKey path: String, _ operation: Query.Operation) -> Query
Parameters
path
The field key path that you are performing your select operation against.
operation
The query operation used in the query.
Return Value
A
Query
to enable chaining. -
Use this method to do a search on
Entries
which enables searching for entries based on value’s queryable coding fromEntryModel.FieldKeys
.Example usage:
let stack = Contentstack.stack(apiKey: apiKey, deliveryToken: deliveryToken, environment: environment) stack.contentType(uid: contentTypeUid).entry().query() .where(queryableCodingKey: .title, .equals("Entry Title")) .find { (result: Result<ContentstackResponse<EntryModel>, Error>, response: ResponseType) in switch result { case .success(let contentstackResponse): // Contentstack response with AssetModel array in items. case .failure(let error): //Error Message } }
Declaration
Swift
public func `where`(queryableCodingKey: EntryModel.FieldKeys, _ operation: Query.Operation) -> Query
Parameters
queryableCodingKey
The member of your
EntryModel.FieldKeys
that you are performing your select operation against.operation
The query operation used in the query.
Return Value
A
Query
to enable chaining. -
Use this method to do a search on
Entries
which enables searching for entries based on value’s for members of referenced entries.Example usage:
let stack = Contentstack.stack(apiKey: apiKey, deliveryToken: deliveryToken, environment: environment) stack.contentType(uid: contentTypeUid).entry().query() .where(referenceAtKeyPath: .title, .equals("Entry Title")) .find { (result: Result<ContentstackResponse<EntryModel>, Error>, response: ResponseType) in switch result { case .success(let contentstackResponse): // Contentstack response with AssetModel array in items. case .failure(let error): //Error Message } }
Declaration
Swift
public func `where`(referenceAtKeyPath keyPath: String, _ operation: Query.Reference) -> Query
Parameters
keyPath
The reference field key path that you are performing your select operation against.
operation
The query operation used in the query.
Return Value
A
Query
to enable chaining. -
When fetching entries, you can sort them in the ascending order with respect to the value of a specific field in the response body.
Example usage:
let stack = Contentstack.stack(apiKey: apiKey, deliveryToken: deliveryToken, environment: environment) stack.contentType(uid: contentTypeUid).entry().query() .orderByAscending(propertyName: .title) .find { (result: Result<ContentstackResponse<EntryModel>, Error>, response: ResponseType) in switch result { case .success(let contentstackResponse): // Contentstack response with AssetModel array in items. case .failure(let error): //Error Message } }
Declaration
Swift
@discardableResult public func orderByAscending(propertyName: EntryModel.FieldKeys) -> Query
Parameters
propertyName
The member of your
EntryModel.FieldKeys
that you are performing order by ascending.Return Value
A
Query
to enable chaining. -
When fetching entries, you can sort them in the decending order with respect to the value of a specific field in the response body.
Example usage:
let stack = Contentstack.stack(apiKey: apiKey, deliveryToken: deliveryToken, environment: environment) stack.contentType(uid: contentTypeUid).entry().query() .orderByDecending(propertyName: .title) .find { (result: Result<ContentstackResponse<EntryModel>, Error>, response: ResponseType) in switch result { case .success(let contentstackResponse): // Contentstack response with AssetModel array in items. case .failure(let error): //Error Message } }
Declaration
Swift
@discardableResult public func orderByDecending(propertyName: EntryModel.FieldKeys) -> Query
Parameters
propertyName
The member of your
EntryModel.FieldKeys
that you are performing order by decending.Return Value
A
Query
to enable chaining. -
Use this method to do a search on
Entries
.Example usage:
let stack = Contentstack.stack(apiKey: apiKey, deliveryToken: deliveryToken, environment: environment) stack.contentType(uid: contentTypeUid).entry().query() .search(for: "searchString") .find { (result: Result<ContentstackResponse<EntryModel>, Error>, response: ResponseType) in switch result { case .success(let contentstackResponse): // Contentstack response with AssetModel array in items. case .failure(let error): //Error Message } }
Declaration
Swift
@discardableResult public func search(for text: String) -> Query
Parameters
text
The text string to match against.
Return Value
A
Query
to enable chaining. -
Use this method to do a search on tags for
Entries
.Example usage:
let stack = Contentstack.stack(apiKey: apiKey, deliveryToken: deliveryToken, environment: environment) stack.contentType(uid: contentTypeUid).entry().query() .tags(for: "tagSearchString") .find { (result: Result<ContentstackResponse<EntryModel>, Error>, response: ResponseType) in switch result { case .success(let contentstackResponse): // Contentstack response with AssetModel array in items. case .failure(let error): //Error Message } }
Declaration
Swift
@discardableResult public func tags(for text: String) -> Query
Parameters
text
The text string to match against.
Return Value
A
Query
to enable chaining. -
Use this method to do a search on
Entries
which enables searching for entries based onQuery.Operator
.Example usage:
let stack = Contentstack.stack(apiKey: apiKey, deliveryToken: deliveryToken, environment: environment) stack.contentType(uid: contentTypeUid).entry().query() .tags(for: "tagSearchString") .find { (result: Result<ContentstackResponse<EntryModel>, Error>, response: ResponseType) in switch result { case .success(let contentstackResponse): // Contentstack response with AssetModel array in items. case .failure(let error): //Error Message } }
Declaration
Swift
public func `operator`(_ operator: Query.Operator) -> Query
Parameters
operator
The member of
Query.Operator
that you are performingReturn Value
A
Query
to enable chaining. -
When fetching entries, you can perform
See moreand
oror
operation.Declaration
Swift
public enum Operator
-
When fetching entries, you can search base on reference
See more$in
or$nin
.Declaration
Swift
public enum Reference
-
When fetching entries, you can search on field key paths.
See moreDeclaration
Swift
public enum Operation
-
The
See moreQuery.Include
is parameter for includingcount
,Unpublished
,ContentType schema
,Global Fields schema
, andReference ContentType Uid
in result.Declaration
Swift
public struct Include : OptionSet