Skip to content

Check If Exists

Description

This operation verifies if a specific key exists in the specified map.

Method

Backendless.Hive(hiveName).MapStore(keyName).keyExists(key): Promise<boolean>;

where:

Argument                Description
hiveName Name of a hive where the operation is performed. String value.
keyName Key name identifying a map. String value.
key Key name identifying a key-value pair to check if it exists. String value.

Return Value

true if an object exists. Otherwise, returns false.

Example

The example below checks if the 'Oranges' key exists in the 'fruits' map.

await Backendless.Hive('groceryStore').MapStore('fruits').keyExists('Oranges')

where:

Argument                Description
'groceryStore' Name of a hive where the operation is performed.
'fruits' Key name identifying a map.

Codeless Reference
map_api_check_if_key_exists

where:

Argument                Description
hive name Name of a hive where the operation is performed.
key name Key name identifying a map.
object key name Key name identifying a key-value pair.

Returns true if an object exists. Otherwise, returns false.

Consider the following Map storage:
map_apI_example_map_store

The example below checks if a key-value pair with the key name "Oranges" exists in the "fruits" map.

map_api_example_check_if_key_exists

The logic produces the following output:

map_api_example_check_if_key_exists_2