Skip to content

Delete By Key Name

Description

This operation deletes a single or multiple key-value pairs from the map.

Method

// Delete One Key-Value Pair
Backendless.Hive(hiveName).MapStore(keyName).deleteKeys(key): Promise<number>;

// Delete Multiple Key-Value Pairs
Backendless.Hive(hiveName).MapStore(keyName).deleteKeys(keys[]): Promise<number>;

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 that must be deleted. String value.
keys An array of string values, where each value represents a key name identifying a key-value pair that must be deleted.

Return Value

The number of key-value pairs deleted from the map. Otherwise, returns 0 if no key-value pairs were deleted.

Example

Delete One Key-Value Pair

The example below deletes the 'Apples' key and the associated value from the map.

await Backendless.Hive('groceryStore').MapStore('fruits').deleteKeys('Apples')

where:

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

Delete Multiple Key-Value Pairs

The example below deletes the 'Apples' and 'Oranges' keys and the associated values from the map.

await Backendless.Hive('groceryStore').MapStore('fruits').deleteKeys(['Apples', 'Oranges'])

where:

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

Codeless Reference

map_api_delete_keys

where:

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

Returns the number of deleted key-value pairs from the map.

Consider the following Map storage:
map_apI_example_map_store

The example below deletes two key-value pairs "Oranges" and "Apples" from the "fruits" map.

map_api_example_delete_keys

The map will look as shown below after the Codeless logic runs:
map_apI_example_map_store_9