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).delete(objKey);

// Delete Multiple Key-Value Pairs
Backendless.Hive(hiveName).MapStore(keyName).delete(objKeys);

where:

Argument                Description
hiveName Name of a hive where the operation is performed. String value.
keyName Key name identifying a map. String value.
objKey Key name identifying a key-value pair that must be deleted. String value.
objKeys 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.

Backendless.Hive("groceryStore").MapStore("fruits").delete("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.

List<String> keys = new ArrayList<>();
keys.add( "Orange" );
keys.add( "Banana" );

Backendless.Hive("groceryStore").MapStore("fruits).delete(keys);

where:

Argument                Description
"groceryStore" Name of a hive where the operation is performed.
"fruits" Key name identifying a map.
keys An array of key names identifying key-value pairs that must be deleted from the 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