-
-
Notifications
You must be signed in to change notification settings - Fork 179
/
keys.go
31 lines (25 loc) · 834 Bytes
/
keys.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
package dynamo
// KeyType is used to specify the type of hash and range keys for tables and indexes.
type KeyType string
// Key types for table and index hash/range keys.
const (
BinaryType KeyType = "B"
StringType KeyType = "S"
NumberType KeyType = "N"
NoneType KeyType = ""
)
// Keyed provides hash key and range key values.
type Keyed interface {
HashKey() interface{}
RangeKey() interface{}
}
// Keys provides an easy way to specify the hash and range keys.
//
// table.Batch("ID", "Month").
// Get(dynamo.Keys{1, "2015-10"}, dynamo.Keys{42, "2015-12"}, dynamo.Keys{42, "1992-02"}).
// All(&results)
type Keys [2]interface{}
// HashKey returns the hash key's value.
func (k Keys) HashKey() interface{} { return k[0] }
// RangeKey returns the range key's value.
func (k Keys) RangeKey() interface{} { return k[1] }