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).[bucketType].keys(StoreKeysOptionsI): Promise<StoreKeysResultI>;
where:
Argument | Description |
---|---|
hiveName |
Name of a hive where the operation is performed. String value. |
[bucketType] |
This placeholder must be substituted with one of the following stores types: KeyValueStore , ListStore , MapStore , SetStore , SortedSetStore . |
StoreKeysOptionsI |
Object containing parameters to specify the page size and the filter pattern. |
StoreKeyResultI |
Object returned after the invocation containing an array of string values(key names). It also returns a cursor value which should be used in the subsequent request to get additional key names. |
The StoreKeysOptionsI
must be an object with the structure shown below:
{
filterPattern: string;
cursor: string;
pageSize: number;
}
where:
Argument | Description |
---|---|
filterPattern |
Optional parameter. A pattern the returned key names must match. Supports the glob format for pattern expressions. If the parameter is not set, defaults to * (all keys). You can specify a pattern with a prefix and/or suffix, for example: filterPattern=leaderboard1*_new_york . It is not recommended to change the filterPattern value during the paging process, since you can retrieve inconsistent data and the cursor value may become invalid. Must be a string value. |
cursor |
Optional parameter. This is a special value used to retrieved additional key names in a paged data set. The value of the cursor is returned in the prior invocation of the operation. The cursor value should be used in conjunction with the pageSize parameter described below. To iterate through all keys in the store, start by setting the cursor to 0; By doing so, you instruct the operation to start the key names retrieval from the very beginning of the collection. Must be a string value. |
pageSize |
Optional parameter. Identifies the number of key names to return in the response. The operation may return key names up to the number specified in the pageSize parameter.Defaults to 5000. |
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
.
await Backendless.Hive('groceryStore').KeyValueStore.keys({
filterPattern: '*',
cursor: '0',
pageSize: '6'
})
where:
Argument | Description |
---|---|
'groceryStore' |
Name of a hive where the operation is performed. |
Response
{
"keys": [
"fruits",
"vegetables",
"fish"
],
"cursor": "185"
}
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. |
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:
The example below retrieves the key names from the key-value storage:
The output will look as shown below after the Codeless logic runs.