QueryOn

public final class QueryOn<EntryType> : Query where EntryType : EntryDecodable

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

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

    Example usage:

    let stack = Contentstack.stack(apiKey: apiKey,
                deliveryToken: deliveryToken,
                environment: environment)
    
    stack.contentType(uid: contentTypeUid).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):
            // Contentstack response with AssetModel array in items.
        case .failure(let error):
            //Error Message
        }
    }
    

    Declaration

    Swift

    public func `where`(queryableCodingKey: EntryType.FieldKeys, _ operation: Query.Operation) -> QueryOn<EntryType>

    Parameters

    queryableCodingKey

    The member of your EntryType.FieldKeys 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(Product.Self)
    .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: EntryType.FieldKeys) -> QueryOn<EntryType>

    Parameters

    propertyName

    The member of your EntryType.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(Product.Self)
    .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: EntryType.FieldKeys) -> QueryOn<EntryType>

    Parameters

    propertyName

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

    Return Value

    A Query to enable chaining.