-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathsdk_keyschema_element.go
41 lines (33 loc) · 1.12 KB
/
sdk_keyschema_element.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// DynamoDB utility
package dynamodb
import (
SDK "github.com/aws/aws-sdk-go/service/dynamodb"
"github.com/evalphobia/aws-sdk-go-wrapper/private/pointers"
)
// NewKeySchema creates new []*SDK.KeySchemaElement.
func NewKeySchema(elements ...*SDK.KeySchemaElement) []*SDK.KeySchemaElement {
if len(elements) > 1 {
schema := make([]*SDK.KeySchemaElement, 2)
schema[0] = elements[0]
schema[1] = elements[1]
return schema
}
schema := make([]*SDK.KeySchemaElement, 1)
schema[0] = elements[0]
return schema
}
// NewKeyElement creates initialized *SDK.KeySchemaElement.
func NewKeyElement(keyName, keyType string) *SDK.KeySchemaElement {
return &SDK.KeySchemaElement{
AttributeName: pointers.String(keyName),
KeyType: pointers.String(keyType),
}
}
// NewHashKeyElement creates initialized *SDK.KeySchemaElement for HashKey.
func NewHashKeyElement(keyName string) *SDK.KeySchemaElement {
return NewKeyElement(keyName, KeyTypeHash)
}
// NewRangeKeyElement creates initialized *SDK.KeySchemaElement for RangeKey.
func NewRangeKeyElement(keyName string) *SDK.KeySchemaElement {
return NewKeyElement(keyName, KeyTypeRange)
}