indexKey
function indexKey(...parts): string | undefined;Builds a DynamoDB key from the given parts. This function is specifically for secondary index keys, where any part can be undefined. If any part is undefined, the function returns undefined.
For primary keys, use the key function instead.
This is specifically useful for building keys for queries on secondary indexes, or for sparse indexes.
Parameters
Section titled “Parameters”The parts to combine into a key.
Returns
Section titled “Returns”string | undefined
The combined key as a string, or undefined if any part is undefined.
Example
Section titled “Example”const key1 = indexKey('part1', 'part2', 'part3') // 'part1#part2#part3'const key2 = indexKey('part1', undefined, 'part3') // undefinedconst key3 = indexKey(undefined, 'part2', 'part3') // undefinedconst key4 = indexKey('part1', 'part2', undefined) // undefined