Query
Query
An initializer is responsible for creating Query object.
| Name | Type | Description |
|---|---|---|
| cachePolicy | CachePolicy | The property to assign cache policy like CACHE_THEN_NETWORK, NETWORK_ELSE_CACHE, NETWORK_ONLY, etc. |
setHeader:forKey:
Set a header for Query
| Name | Type | Description |
|---|---|---|
| headerValue (required) | NSString | The header value |
| headerKey (required) | NSString | The header key |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" <span>environmentName:@"ENVIRONMENT"]; ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"]; Query * query = [contentType query]; [query setHeader:@"MyValue" forKey:@"My-Custom-Header"];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.setHeader("MyValue", forKey: "My-Custom-Header")addHeadersWithDictionary:
Set a header for Query
| Name | Type | Description |
|---|---|---|
| headers (required) | NSDictionary<NSString*,NSString*> | The headers as dictionary which needs to be added to the application. |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Query * query = [contentType query];
[query addHeadersWithDictionary:@{@"My-Custom-Header": @"MyValue"}];Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.addHeadersWithDictionary(["My-Custom-Header":"MyValue"])removeHeaderForKey:
Removes a header from this Query.
| Name | Type | Description |
|---|---|---|
| headerKey (required) | NSString | The header key that needs to be removed. |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" <span>environmentName:@"ENVIRONMENT"]; ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"]; Query * query = [contentType query]; [query removeHeaderForKey:@"key"];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.removeHeaderForKey("key")locale:
This method provides all the entries for the specified language in the response.
| Name | Type | Description |
|---|---|---|
| locale (required) | NSString | Language enum for all language available. |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"]; ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"]; Query * query = [contentType query]; [query locale:@“en-us”];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.locale(“en-us”)tags:
This method provides only the entries that contain tags matching the ones mentioned in the function.
| Name | Type | Description |
|---|---|---|
| tagsArray (required) | NSArray<NSString*> | An array of tags that are to be included for the key |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"]; ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"]; Query * query = [contentType query]; [query tags:@[@"phone", @"laptop"]];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.tags(["phone", "laptop"])orWithSubqueries:
This method performs the OR operation on the specified query objects and provides only the matching entries.
| Name | Type | Description |
|---|---|---|
| queries (required) | NSArray<Query*> | Array of queries to be taken into consideration. |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"]; ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"]; Query *query1 = [contentType query]; [query1 whereKey:@"total_hits" greaterThanOrEqualTo:@(800)]; Query *query2 = [contentType query]; [query2 whereKey:@"total_hits" lessThanOrEqualTo:@(1200)]; Query * query = [contentType query]; [query orWithSubqueries:@[query1, query2]];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
var query1:Query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query1.whereKey("total_hits", greaterThanOrEqualTo:800)
var query2:Query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query2.whereKey("total_hits", equalTo:1200)
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.orWithSubqueries([query1, query2])andWithSubqueries:
This method performs the AND operation on the specified query objects and provides only the matching entries.
| Name | Type | Description |
|---|---|---|
| queries (required) | NSArray<Query*> | Array of queries to be taken into consideration. |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"]; ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"]; Query *query1 = [contentType query]; [query1 whereKey:@"total_hits" greaterThanOrEqualTo:@(800)]; Query *query2 = [contentType query]; [query2 whereKey:@"total_hits" lessThanOrEqualTo:@(1200)]; Query * query = [contentType query]; [query andWithSubqueries:@[query1, query2]];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
var query1:Query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query1.whereKey("total_hits", greaterThanOrEqualTo:800)
var query2:Query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query2.whereKey("total_hits", equalTo:1200)
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.andWithSubqueries([query1, query2])orderByAscending:
Sorts the provided entries in the ascending order on the basis of the specified field.
| Name | Type | Description |
|---|---|---|
| key (required) | NSString | The field uid based on which the ordering should be done. |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"]; ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"]; Query * query = [contentType query]; [query orderByAscending:@"updated_at"];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.orderByAscending("updated_at")orderByDescending:
Sorts the provided entries in the descending order on the basis of the specified field.
| Name | Type | Description |
|---|---|---|
| key (required) | NSString | The field uid based on which the ordering should be done. |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"]; ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"]; Query * query = [contentType query]; [query orderByDescending:@"updated_at"];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.orderByDescending("updated_at")objectsCount
Provides only the number of entries with values matching the specified values for a field.
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"]; ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"]; Query * query = [contentType query]; [query objectsCount];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.objectsCount()includeContentType
This method also includes the contenttype for the entries returned in the response.
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"]; ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"]; Query * query = [contentType query]; [query includeContentType];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.includeContentType()includeFallback
Retrieve the published content of the fallback locale entry if the entry is not localized in specified locale.
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"]; ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"]; Query * query = [contentType query]; [query includeFallback];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.includeFallback()includeBranch
Retrieve the branch for the published content.
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"]; ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"]; Query * query = [contentType query]; [query includeBranch];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.includeBranch()includeReferenceContentTypeUid
This method also includes the content type UIDs of the referenced entries returned in the response.
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"]; ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"]; Query * query = [contentType query]; [query includeReferenceContentTypeUid];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.includeReferenceContentTypeUid()includeEmbeddedItems
Include Embedded Objects (Entries and Assets) along with entry/entries details.
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"]; ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"]; Query * query = [contentType query]; [query includeEmbeddedItems];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.includeEmbeddedItems()includeCount
This method also includes the total number of entries returned in the response.
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"]; ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"]; Query * query = [contentType query]; [query includeCount];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.includeCount()limitObjects:
This method limits the response by providing only the specified number of entries.
| Name | Type | Description |
|---|---|---|
| number (required) | NSNumber | Number of entries to be returned |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"]; ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"]; Query * query = [contentType query]; [query limitObjects:@(5)];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.limitObjects(NSNumber(int:5))skipObjects:
This method provide response by skipping only the specified number of entries.
| Name | Type | Description |
|---|---|---|
| number (required) | NSNumber | Number of entries to be skipped before returned. |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"]; ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"]; Query * query = [contentType query]; [query skipObjects:@(5)];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.skipObjects(NSNumber(int:5))addQueryWithKey:andValue:
Include custom query using a key and a value.
| Name | Type | Description |
|---|---|---|
| key (required) | NSString | The name of the key to be added. |
| value (required) | id | The value for the query key. |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"]; ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"]; Query * query = [contentType query]; [query addQueryWithKey:@"key_name" andValue:@"MyValue"];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.addQueryWithKey("key_name", andValue:"MyValue")addQueryParams:
A custom dictionary can be provided to a query that can specify the conditions for retrieving objects.
| Name | Type | Description |
|---|---|---|
| queryDict (required) | NSDictionary<NSString*,id> | A dictionary with all the necessary conditions for retrieving objects. |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Query * query = [contentType query];
[query addQueryParams:@{@"Query_Key":@"Query Value"}];Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.addQueryParams(["Query_Key":"Query Value"])removeQueryWithKey:
Removes custom query.
| Name | Type | Description |
|---|---|---|
| key (required) | NSString | The name of the query. |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"]; ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"]; Query * query = [contentType query]; [query removeQueryWithKey:@"Query_Key"];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.removeQueryWithKey("Query_Key")whereKey:equalTo:
This method provides only the entries matching the specified value for a field.
| Name | Type | Description |
|---|---|---|
| key (required) | NSString | Uid of the field that is to be taken into consideration |
| object (required) | id | The value used to match or compare |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"]; ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"]; Query * query = [contentType query]; [query whereKey:@"title" equalTo:@"Welcome"];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.whereKey("title", equalTo:"Welcome")whereKey:notEqualTo:
This method provides only the entries with values not equal to the specified value for a field.
| Name | Type | Description |
|---|---|---|
| key (required) | NSString | Uid of the field that is to be taken into consideration |
| object (required) | id | The value used to match or compare |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"]; ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"]; Query * query = [contentType query]; [query whereKey:@"title" notEqualTo:@"Welcome"];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.whereKey("title", notEqualTo:"Welcome")whereKey:lessThan:
This method provides only the entries with a values less than the specified value for a field.
| Name | Type | Description |
|---|---|---|
| key (required) | NSString | Uid of the field that is to be taken into consideration |
| object (required) | id | The value used to match or compare |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"]; ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"]; Query * query = [contentType query]; [query whereKey:@"created_at" lessThan:@"2015-03-12"];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.whereKey("created_at", lessThan:"2015-03-12")whereKey:greaterThan:
This method provides only the entries with values greater than the specified value for a field.
| Name | Type | Description |
|---|---|---|
| key (required) | NSString | Uid of the field that is to be taken into consideration |
| object (required) | id | The value used to match or compare |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"]; ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"]; Query * query = [contentType query]; [query whereKey:@"created_at" greaterThan:@"2015-03-12"];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.whereKey("created_at", greaterThan:"2015-03-12")whereKey:lessThanOrEqualTo:
This method provides only the entries with values less than or equal to the specified value for a field.
| Name | Type | Description |
|---|---|---|
| key (required) | NSString | Uid of the field that is to be taken into consideration |
| object (required) | id | The value used to match or compare |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"]; ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"]; Query * query = [contentType query]; [query whereKey:@"created_at" lessThanOrEqualTo:@"2015-03-12"];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.whereKey("created_at", lessThanOrEqualTo:"2015-03-12")whereKey:greaterThanOrEqualTo:
This method provides only the entries with values greater than or equal to the specified value for a field.
| Name | Type | Description |
|---|---|---|
| key (required) | NSString | Uid of the field that is to be taken into consideration |
| object (required) | id | The value used to match or compare |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"]; ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"]; Query * query = [contentType query]; [query whereKey:@"created_at" greaterThanOrEqualTo:@"2015-03-12"];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.whereKey("created_at", greaterThanOrEqualTo:"2015-03-12")whereKey:containedIn:
This method provides only the entries with values matching the specified values for a field.
| Name | Type | Description |
|---|---|---|
| key (required) | NSString | Uid of the field that is to be taken into consideration |
| array (required) | NSArray | An array of values that are to be used to match or compare |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"]; ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"]; Query * query = [contentType query]; [query whereKey:@"title" containedIn:@["Demo", @"Welcome"]];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.whereKey("title", containedIn:["Demo", "Welcome"])whereKey:notContainedIn:
This method provides only the entries that do not contain values matching the specified values for a field.
| Name | Type | Description |
|---|---|---|
| key (required) | NSString | Uid of the field that is to be taken into consideration |
| array (required) | NSArray | An array of values that are to be used to match or compare |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"]; ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"]; Query * query = [contentType query]; [query whereKey:@"title" notContainedIn:@["Demo", @"Welcome"]];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.whereKey("title", notContainedIn:["Demo", "Welcome"])whereKeyExists:
This method provides only the entries that contains the field matching the specified field uid.
| Name | Type | Description |
|---|---|---|
| key (required) | NSString | Uid of the field that is to be taken into consideration |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"]; ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"]; Query * query = [contentType query]; [query whereKeyExists:@"introduction"];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.whereKeyExists("introduction")whereKeyDoesNotExist:
This method provides only the entries that do not contain the field matching the specified field uid.
| Name | Type | Description |
|---|---|---|
| key (required) | NSString | Uid of the field that is to be taken into consideration |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"]; ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"]; Query * query = [contentType query]; [query whereKeyDoesNotExist:@"introduction"];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.whereKeyDoesNotExist("introduction")whereKey:matchesRegex:
This method provides only the entries matching the regular expression for the specified field.
| Name | Type | Description |
|---|---|---|
| key (required) | NSString | Uid of the field that is to be taken into consideration |
| regex (required) | NSString | The value used to match or compare |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"]; ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"]; Query * query = [contentType query]; [query whereKey:@"title" matchesRegex:@"^wel"];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.whereKey("title", matchesRegex:"^wel")whereKey:matchesRegex:modifiers:
This method provides only the entries matching the regular expression for the specified field.
| Name | Type | Description |
|---|---|---|
| key (required) | NSString | Uid of the field that is to be taken into consideration |
| regex (required) | NSString | The value used to match or compare |
| modifier (required) | NSString | Modifiers for regex options. Specify ‘i’ as the option to ignore the case. |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"]; ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"]; Query * query = [contentType query]; [query whereKey:@"title" matchesRegex:@"^wel" modifiers:@"i"];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.whereKey("title", matchesRegex:"^wel", modifiers:"i")whereKey:in:
This method provides only the entries matching the Query.
| Name | Type | Description |
|---|---|---|
| key (required) | NSString | Reference Uid of the field that is to be taken into consideration. |
| query (required) | Query | Query to be taken into consideration |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"]; ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"]; Query * query = [contentType query]; Query * reference = [contentType query]; [reference whereKey:@"name" equalTo:@"Author"]; [query whereKey:@"author" in:reference];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
var reference:Query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
reference.whereKey("name", equalTo:"Author")
query.whereKey("author", in:reference)whereKey:notIn:
This method provides only the entries matching the Query.
| Name | Type | Description |
|---|---|---|
| key (required) | NSString | Reference Uid of the field that is to be taken into consideration. |
| query (required) | Query | Query to be taken into consideration |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"]; ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"]; Query * query = [contentType query]; Query * reference = [contentType query]; [reference whereKey:@"name" equalTo:@"Author"]; [query whereKey:@"author" notIn:reference];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
var reference:Query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
reference.whereKey("name", equalTo:"Author")
query.whereKey("author", notIn:reference)onlyFields:
This method provides only the entries that match the specified field uids and corresponding values.
| Name | Type | Description |
|---|---|---|
| fieldUIDs (required) | NSArray | An array of values that are to be included for the key |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"]; ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"]; Query * query = [contentType query]; [query onlyFields:@[@"attachments"]];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.onlyFields(["attachments"])exceptFields:
This method provides all entries except those that match the specified field uids and corresponding values.
| Name | Type | Description |
|---|---|---|
| fieldUIDs (required) | NSArray | An array of values that are to be included for the key |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"]; ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"]; Query * query = [contentType query]; [query exceptFields:@[@"attachments"]];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.exceptFields(["attachments"])includeReferenceFieldWithKey:
This method provides all entries that also contain data from the referred entry in the specified field.
| Name | Type | Description |
|---|---|---|
| key (required) | NSString | Uid of the reference field that is to be taken into consideration |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"]; ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"]; Query * query = [contentType query]; [query includeReferenceFieldWithKey:@"entry_a"];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.includeReferenceFieldWithKey(@"entry_a")includeReferenceFieldWithKey:onlyFields:
This method provides all entries including referred entry containing only specified fields.
| Name | Type | Description |
|---|---|---|
| key (required) | NSString | Uid of the reference field that is to be taken into consideration |
| fieldUIDs (required) | NSArray<NSString*> * | Uid of the reference field that is to be taken into consideration |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"]; ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"]; Query * query = [contentType query]; [query includeReferenceFieldWithKey:@"entry_a" onlyFields:@[@"attachments"]];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.includeReferenceFieldWithKey(@"entry_a", onlyFields:["attachments"])includeReferenceFieldWithKey:excludingFields:
This method provides all entries including referred entry containing all fields except specified fields.
| Name | Type | Description |
|---|---|---|
| key (required) | NSString | Uid of the reference field that is to be taken into consideration |
| fieldUIDs (required) | NSArray<NSString*> * | Uid of the reference field that is to be taken into consideration |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"]; ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"]; Query * query = [contentType query]; [query includeReferenceFieldWithKey:@"entry_a" excludingFields:@[@"attachments"]];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.includeReferenceFieldWithKey(@"entry_a", excludingFields:["attachments"])addParamKey:andValue:
This method provides all the entries from a specified ContentType.
| Name | Type | Description |
|---|---|---|
| key (required) | NSString | The key as string which needs to be added to the Query |
| value (required) | The value as string which needs to be added to the Query |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"]; ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"]; Query * query = [contentType query]; [query addParamKey:@"key" andValue:@"value"];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.addParamKey("key", andValue:"value")find:
This method provides all the entries from a specified ContentType.
Note By default, the limit for response details per request is 100, with the maximum limit set at 250.
| Name | Type | Description |
|---|---|---|
| completionBlock (required) | (void ( ^ ) ( ResponseType type , Entry *BUILT_NULLABLE_P entry , NSError *BUILT_NULLABLE_P error )) | Block to be called once operation is done. |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Query * query = [contentType query];
[query find:^(ResponseType type, Entry *entry, NSError *error){
}];Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.find({(responseType, entry!, error!) -> in
})findOne:
This method provides the first entry from a specified ContentType.
| Name | Type | Description |
|---|---|---|
| completionBlock (required) | (void ( ^ ) ( ResponseType type , Entry *BUILT_NULLABLE_P entry , NSError *BUILT_NULLABLE_P error )) | Block to be called once operation is done. |
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Query * query = [contentType query];
[query findOne:^(ResponseType type, Entry *entry, NSError *error){
}];Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.findOne({(responseType, entry!, error!) -> in
})