QueryOn

View as Markdown

QueryOn

To fetch all or find Entries and Querying for Specific Model use QueryOn.

where(queryableCodingKey:_:)

Use this method to do a search on Entries which enables searching for entries based on value’s queryable coding from `EntryType.FieldKeys`.

NameTypeDescription
queryableCodingKey (required)EntryType.FieldKeys

The member of your EntryType.FieldKeys 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(uid: "<CONTENT_TYPE_UID>").entry().query(Product.Self)

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

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

    switch result {

    case .success(let contentstackResponse):

        

    case .failure(let error):

        

    }

}

orderByAscending(propertyName:)

When fetching entries, you can sort them in the ascending order with respect to the value of a specific field in the response body.

NameTypeDescription
propertyName (required)EntryType.FieldKeys

The member of your EntryType.FieldKeys that you are performing order by ascending.

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

stack.contentType(uid: "<CONTENT_TYPE_UID>").entry().query(Product.Self)

.orderByAscending(propertyName: .title)

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

    switch result {

    case .success(let contentstackResponse):


    case .failure(let error):


    }

}

orderByDecending(propertyName:)

When fetching entries, you can sort them in the decending order with respect to the value of a specific field in the response body.

NameTypeDescription
propertyName (required)EntryType.FieldKeys

The member of your EntryType.FieldKeys that you are performing order by descending.

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

stack.contentType(uid: "<CONTENT_TYPE_UID>").entry().query(Product.Self)

.orderByDecending(propertyName: .title)

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

    switch result {

    case .success(let contentstackResponse):


    case .failure(let error):


    }

}