-
Notifications
You must be signed in to change notification settings - Fork 14
/
request_get_item.go
68 lines (55 loc) · 1.5 KB
/
request_get_item.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package dynago
type getItemRequest struct {
TableName string
Key Document
ProjectionExpression string `json:",omitempty"`
expressionAttributes
// TODO ReturnConsumedCapacity string
ConsistentRead bool `json:",omitempty"`
}
func newGetItem(client *Client, table string, key Document) *GetItem {
return &GetItem{
client: client,
req: getItemRequest{
TableName: table,
Key: key,
},
}
}
type GetItem struct {
client *Client
req getItemRequest
}
// Set the ProjectionExpression for this GetItem (which attributes to get)
func (p GetItem) ProjectionExpression(expression string) *GetItem {
p.req.ProjectionExpression = expression
return &p
}
// Shortcut to set an ExpressionAttributeValue for used in expression query
func (p GetItem) Param(key string, value interface{}) *GetItem {
p.req.paramHelper(key, value)
return &p
}
func (p GetItem) Params(params ...Params) *GetItem {
p.req.paramsHelper(params)
return &p
}
// Set up this get to be a strongly consistent read.
func (p GetItem) ConsistentRead() *GetItem {
p.req.ConsistentRead = true
return &p
}
// Execute the get item.
func (p *GetItem) Execute() (result *GetItemResult, err error) {
return p.client.executor.GetItem(p)
}
func (e *awsExecutor) GetItem(g *GetItem) (result *GetItemResult, err error) {
result = &GetItemResult{}
err = e.makeRequestUnmarshal("GetItem", &g.req, result)
return
}
// The result from executing a GetItem.
type GetItemResult struct {
Item Document
ConsumedCapacity interface{} // TODO
}