Skip to content

Get Key Names

Description

This operation retrieves key names from a specific store type. Key names are retrieved with paging, the default page size is 10,000 items. The operation supports filtering, where the returned key names match the specified pattern.

Method

Backendless.Hive(hiveName).StoreType().keys(name, filterPattern, cursor, pageSize);

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.

Return Value

An object with the following structure:

{  
  "keys": [  
    "key_name_1",  
    "key_name_2"  
  ],  
  "cursor": "182"  
}

The cursor value of "0" in the response indicates that you have reached the end of the store and there are no keys left to return. In some cases you can get more keys than specified in the pageSize parameter.

Example

The example below may return up to six key names from the key-value store, since the pageSize parameter is set to 6.

Backendless.Hive("groceryStore").KeyValueStore().keys( "*", "0", 6 );

where:

Argument                Description
"groceryStore" Name of a hive where the operation is performed.

Response

{  
    "keys": [  
     "fruits",  
     "vegetables",  
     "fish"  
    ],  
    "cursor": "185"  
}

Codeless Reference

general_api_get_key_names

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.
filter pattern A pattern to filter the keys with. Only the keys matching the pattern will be returned by the operation
page size Identifies the number of keys to return in the response. Operation may return up to the specified number of key names. Refer to the section above for more information.
cursor A value received in the response of a prior call of the same block. Refer to the section above for more information.

Returns an object containing key names and the cursor position.

Consider the following Key Value storage:

sample-key-value

The example below retrieves the key names from the key-value storage:

general_api_example_get_key_names
The output will look as shown below after the Codeless logic runs.
general_api_example_get_key_names_2