Union¶
Description¶
This operation creates a union of values from the specified sorted sets. A union is a set made by combining the elements of two or more sets. When a value appears in more than one input sorted set, the resulting score is a sum of the scores from each sorted set.
Method¶
Backendless.Hive( hiveName ).SortedSetStore.union( keyNames ): Promise<values>;
where:
Argument | Description |
---|---|
hiveName |
Name of a hive where the operation is performed. Must be a string value. |
keyNames |
Key names identifying sorted sets for the operation. Must be an array of string values. |
Return Value¶
An array of combined values from all input sorted sets (duplicates excluded). The structure of the response is an array of arrays. Each individual element of the top level array is an array consisting of two elements - score and value. The score is the sum of all individual scores for the corresponding values from all referenced sorted sets.
Example¶
Consider the following sorted sets:
The example below retrieves a union of values from the sample sorted sets shown above:
await Backendless.Hive( 'demoHive' ).SortedSetStore.union( [League1Players', 'League2Players'] )
where:
Argument | Description |
---|---|
'demoHive' |
Name of a hive where the operation is performed. |
['LeaguePlayers', 'League2Players'] |
Names of the sorted set to get a union of the values of. |
Response
[
[
11,
"Charlie"
],
[
13,
"Adam"
],
[
24,
"Frank"
],
[
26,
"Dave"
],
[
28,
"Bobby"
]
]
Codeless Reference¶
where:
Argument | Description |
---|---|
hive name |
Name of a hive where the operation is performed. |
key names |
A list containing key names identifying unique sorted sets. |
Returns a list of combined values from all input sorted sets (duplicates excluded). The structure of the response is a list of lists. Each individual element of the top level list is a list consisting of two elements - score and value. The score is the sum of all individual scores for the corresponding values from all referenced sorted sets.
Consider the following Sorted Set storage:
The example below retrieves a union of values from the sample sorted sets shown above:
The output will look as shown below after the Codeless logic runs. For identical values found in the specified sorted sets the score is summed.