forked from dugancathal/dynago
-
Notifications
You must be signed in to change notification settings - Fork 0
/
request_delete_item.go
68 lines (56 loc) · 1.67 KB
/
request_delete_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 deleteItemRequest struct {
TableName string
Key Document
ConditionExpression string `json:",omitempty"`
expressionAttributes
// TODO ReturnItemCollectionMetrics
ReturnConsumedCapacity CapacityDetail `json:",omitempty"`
ReturnValues ReturnValues `json:",omitempty"`
}
func newDeleteItem(client *Client, table string, key Document) *DeleteItem {
return &DeleteItem{
executor: client.executor,
req: deleteItemRequest{
TableName: table,
Key: key,
},
}
}
type DeleteItem struct {
executor Executor
req deleteItemRequest
}
// Set a ConditionExpression to do a conditional DeleteItem.
func (d DeleteItem) ConditionExpression(expression string, params ...Params) *DeleteItem {
d.req.ConditionExpression = expression
d.req.paramsHelper(params)
return &d
}
func (d DeleteItem) ReturnConsumedCapacity(consumedCapacity CapacityDetail) *DeleteItem {
d.req.ReturnConsumedCapacity = consumedCapacity
return &d
}
// Set ReturnValues. For DeleteItem, it can only be ReturnAllOld
func (d DeleteItem) ReturnValues(returnValues ReturnValues) *DeleteItem {
d.req.ReturnValues = returnValues
return &d
}
/*
Actually Execute this putitem.
DeleteItemResult will be nil unless ReturnValues is set.
*/
func (d *DeleteItem) Execute() (res *DeleteItemResult, err error) {
return d.executor.DeleteItem(d)
}
func (e *AwsExecutor) DeleteItem(d *DeleteItem) (res *DeleteItemResult, err error) {
if d.req.ReturnValues != ReturnNone && d.req.ReturnValues != "" {
err = e.MakeRequestUnmarshal("DeleteItem", &d.req, &res)
} else {
_, err = e.makeRequest("DeleteItem", &d.req)
}
return
}
type DeleteItemResult struct {
Attributes Document
}