Check If Keys Exist¶
Description¶
This operation checks if specific keys exist in the specified store.
Method¶
// Check One Key
[[[Backendless.shared hive:(NSString *)hiveName] storeType] existsWithKey:(NSString *)key responseHandler:^(BOOL)responseHandler errorHandler:^(Fault *)errorHandler];
// Check Multiple Keys
[[[Backendless.shared hive:(NSString *)hiveName] storeType] existsWithKeys:(NSArray<NSString *> *)keys responseHandler:^(NSInteger)responseHandler errorHandler:^(Fault *)errorHandler];
// Check One Key
Backendless.shared.hive(hiveName: String).storeType.exists(key: String, responseHandler: ((Bool) -> Void)!, errorHandler: ((Fault) -> Void)!)
// Check Multiple Keys
Backendless.shared.hive(hiveName: String).storeType.exists(keys: [String], responseHandler: ((Int) -> Void)!, errorHandler: ((Fault) -> Void)!)
where:
Argument | Description |
---|---|
hiveName |
Name of a hive where the operation is performed. String value. |
storeType |
This placeholder must be substituted with one of the following stores types: keyValueStore , listStore , mapStore , setStore , sortedSetStore . |
keys |
Represents an array of keys to check if they exist in a store. Array of string values. |
key |
Identifies a single key to check if it exists in a store. String value. |
Return Value¶
Number of found keys. Otherwise, 0
is returned if the specified keys do not exist.
Example¶
Check One Key
This example checks if the "fruits"
key exists in the key-value store.
[[[Backendless.shared hive:@"groceryStore"] keyValueStore] existsWithKey:@"fruits" responseHandler:^(BOOL response) {
// handle response
} errorHandler:^(Fault *fault) {
// handle error
}];
Backendless.shared.hive("groceryStore").keyValueStore.exists(key: "fruits", responseHandler: { response in
// handle response
}, errorHandler: { fault in
// handle error
})
where:
Argument | Description |
---|---|
"groceryStore" |
Name of the hive where the operation is performed. |
"fruits" |
Key name to check for existence. |
Check Multiple Keys
The example below checks if the "fruits"
and "vegetables"
keys exist in the key-value store.
[[[Backendless.shared hive:@"groceryStore"] keyValueStore] existsWithKey:@"fruits" responseHandler:^(BOOL response) {
// handle response
} errorHandler:^(Fault *fault) {
// handle error
}];
Backendless.shared.hive("groceryStore").keyValueStore.exists(key: "fruits", responseHandler: { response in
// handle response
}, errorHandler: { fault in
// handle error
})
where:
Argument | Description |
---|---|
"groceryStore" |
Name of the hive where the operation is performed. |
["fruits","vegetables"] |
An array of key names to check for existence. |
Codeless Reference¶
where:
Argument | Description |
---|---|
hive name |
Name of a hive where the operation is performed. |
type |
Storage type, can be one of the following: Key / Value, Sorted Set, Set, Map, List. |
keys |
An array of keys to check for existence. |
Returns the number of found keys. Otherwise, 0
is returned if the specified keys do not exist.
Consider the following Key Value storage:
The example below checks if the "Japan"
and "USA"
keys exist in the the Key Value storage of the countries
hive. The block returns a number of keys found in the store.
The output will look as shown below after the Codeless logic runs.
To check for a single key, use the following block. The blocks returns a boolean true
or false
value indicating whether the specific key exists in the store.
where:
Argument | Description |
---|---|
hive name |
Name of a hive where the operation is performed. |
type |
Type of the storage used for this operation. |
key name |
Key name to check for existence. |
The example below checks if the "Japan"
key exists in the Key / Value
store of the countries
hive:
The output will look as shown below after the Codeless logic runs.