(key string, value Value)
| 226 | } |
| 227 | |
| 228 | func (c Client) incr(key string, value Value) (newValue ReturnValue, err error) { |
| 229 | builder := newExpresionBuilder() |
| 230 | builder.keys[vk] = struct{}{} |
| 231 | resp, err := c.ddbClient.UpdateItemRequest(&dynamodb.UpdateItemInput{ |
| 232 | ExpressionAttributeNames: builder.expressionAttributeNames(), |
| 233 | ExpressionAttributeValues: map[string]dynamodb.AttributeValue{ |
| 234 | ":delta": value.ToAV(), |
| 235 | }, |
| 236 | Key: keyDef{pk: key, sk: emptySK}.toAV(c), |
| 237 | ReturnValues: dynamodb.ReturnValueAllNew, |
| 238 | TableName: aws.String(c.table), |
| 239 | UpdateExpression: aws.String("ADD #val :delta"), |
| 240 | }).Send(context.TODO()) |
| 241 | |
| 242 | if err == nil { |
| 243 | newValue = ReturnValue{resp.UpdateItemOutput.Attributes[vk]} |
| 244 | } |
| 245 | |
| 246 | return |
| 247 | } |
| 248 | |
| 249 | // INCR increments the number stored at the key by 1 (n = n + 1) and returns the new value. If the |
| 250 | // key does not exist, it will be initialized with zero before applying the operation. |
no test coverage detected