KeySpec

sealed interface KeySpec<K : KeyType>

Defines the specification for a partition or sort key, including the names and types of its attributes. Key specifications are an important component of item schemas since they describe how to interact with each key attribute and provide vital typing information for features which interact with DynamoDB operations like Query and Scan.

A KeySpec consisting of a single attribute may be created manually by invoking one the companion object methods byteArray, number, or string. A KeySpec consisting of more attributes may be created by invoking one of the extension methods thenInt, thenLong, thenString, etc. Key specifications may consist of up to four attributes.

Important: The order of attributes within a KeySpec is significant and must reflect the order of the attributes defined in the table or index key within DynamoDB.

Examples

To create a key specification for a single attribute:

val spec = KeySpec.int("companyId") // returns KeySpec.Key1<Int>

To create a key specification for multiple attributes:

val spec = KeySpec
.int("companyId") // returns KeySpec.Key1<Int>
.thenString("department") // returns KeySpec.Key2<Int, String>
.thenLong("timestamp") // returns KeySpec.Key3<Int, String, Long>

Type Parameters

K

The type of the key, either KeyType or one of its specific derivations

Inheritors

Types

Link copied to clipboard
object Companion
Link copied to clipboard
interface Key1<K1> : KeySpec<KeyType.Key1<K1>>

Defines the specification for a key consisting of a single attribute

Link copied to clipboard
interface Key2<K1, K2> : KeySpec<KeyType.Key2<K1, K2>>

Defines the specification for a key consisting of two attributes

Link copied to clipboard
interface Key3<K1, K2, K3> : KeySpec<KeyType.Key3<K1, K2, K3>>

Defines the specification for a key consisting of three attributes

Link copied to clipboard
interface Key4<K1, K2, K3, K4> : KeySpec<KeyType.Key4<K1, K2, K3, K4>>

Defines the specification for a key consisting of four attributes

Properties

Link copied to clipboard
abstract val converter: ItemConverter<K>

An ItemConverter instance which converts between K values and Item values