ContentTypeQuery

View as Markdown

ContentTypeQuery

To fetch all or find ContentType use ContentTypeQuery.

NameTypeDescription
cachePolicy CachePolicy

Set cache policy for the ContentTypeQuery request.

stack Stack

Stack instance for ContentTypeQuery to be fetched



parameters [String : Any]

URI Parameters.

queryParameter [String : Any]

Query parameter

where(queryableCodingKey:_:)

Use this method to do a search on ContentType which enables searching for entries based on value’s for members of referenced entries.

NameTypeDescription
queryableCodingKey (required)ContentTypeModel.QueryableCodingKey

The member of your QueryableCodingKey that you are performing your select operation against.

operation (required)Query.Operation

The query operation used in the query.

let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")


stack.contentType().query()

.where(queryableCodingKey: .title, .equals("ContentType Title"))

.find { (result: Result<ContentstackResponse<ContentTypeModel>, Error>, response: ResponseType) in

    switch result {

    case .success(let contentstackResponse):

        // Contentstack response with ContentTypeModel array in items.

    case .failure(let error):

        //Error Message

    }

}

include(params:)

Include URI parametes to fetch ContentType with Global Fields and Count.

NameTypeDescription
params (required)ContentTypeQuery.Include

The member of your ContentTypeQuery.Include that you want to include in response

let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")


stack.contentType().query().include(params: [.all])

.find { (result: Result<ContentstackResponse<ContentTypeModel>, Error>, response: ResponseType) in

    switch result {

    case .success(let contentstackResponse):

        // Contentstack response with ContentTypeModel array in items.

    case .failure(let error):

        //Error Message

    }

}

let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")

stack.contentType().query().include(params: [.count]) 

.find { (result: Result<ContentstackResponse<ContentTypeModel>, Error>, response: ResponseType) in 

  switch result { 

  case .success(let contentstackResponse): 


  case .failure(let error): 

  }

}

includeMetadata()

Includes ContentTypeQuery metadata along with response body

let stack = Contentstack.stack(apiKey: apiKey,

 deliveryToken: deliveryToken,

  environment: environment)

  

stack.contentType(uid: contentTypeUID).entry().includeMetadata().query()