Class: AWSCDK::DynamoDB::CfnGlobalTable::KeySchemaProperty

Inherits:
Jsii::Struct
  • Object
show all
Defined in:
dynamo_db/cfn_global_table.rb

Overview

Represents a single element of a key schema.

A key schema specifies the attributes that make up the primary key of a table, or the key attributes of an index.

A KeySchemaElement represents exactly one attribute of the primary key. For example, a simple primary key would be represented by one KeySchemaElement (for the partition key). A composite primary key would require one KeySchemaElement for the partition key, and another KeySchemaElement for the sort key.

A KeySchemaElement must be a scalar, top-level attribute (not a nested attribute). The data type must be one of String, Number, or Binary. The attribute cannot be nested within a List or a Map.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attribute_name:, key_type:) ⇒ KeySchemaProperty

Returns a new instance of KeySchemaProperty.

Parameters:

  • attribute_name (String)

    The name of a key attribute.

  • key_type (String)

    The role that this key attribute will assume:.



1158
1159
1160
1161
1162
1163
# File 'dynamo_db/cfn_global_table.rb', line 1158

def initialize(attribute_name:, key_type:)
  @attribute_name = attribute_name
  Jsii::Type.check_type(@attribute_name, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "attributeName")
  @key_type = key_type
  Jsii::Type.check_type(@key_type, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "keyType")
end

Instance Attribute Details

#attribute_nameString (readonly)

The name of a key attribute.



1169
1170
1171
# File 'dynamo_db/cfn_global_table.rb', line 1169

def attribute_name
  @attribute_name
end

#key_typeString (readonly)

The role that this key attribute will assume:.

  • HASH - partition key
  • RANGE - sort key

The partition key of an item is also known as its hash attribute . The term "hash attribute" derives from DynamoDB's usage of an internal hash function to evenly distribute data items across partitions, based on their partition key values.

The sort key of an item is also known as its range attribute . The term "range attribute" derives from the way DynamoDB stores items with the same partition key physically close together, in sorted order by the sort key value.



1181
1182
1183
# File 'dynamo_db/cfn_global_table.rb', line 1181

def key_type
  @key_type
end

Class Method Details

.jsii_propertiesObject



1183
1184
1185
1186
1187
1188
# File 'dynamo_db/cfn_global_table.rb', line 1183

def self.jsii_properties
  {
    :attribute_name => "attributeName",
    :key_type => "keyType",
  }
end

Instance Method Details

#to_jsiiObject



1190
1191
1192
1193
1194
1195
1196
1197
# File 'dynamo_db/cfn_global_table.rb', line 1190

def to_jsii
  result = {}
  result.merge!({
    "attributeName" => @attribute_name,
    "keyType" => @key_type,
  })
  result.compact
end