(key string, element Value, side LSide, flags Flags)
| 420 | } |
| 421 | |
| 422 | func (c Client) listPushActions(key string, element Value, side LSide, flags Flags) (actions []dynamodb.TransactWriteItem, err error) { |
| 423 | node := listNode{ |
| 424 | key: key, |
| 425 | value: ReturnValue{element.ToAV()}, |
| 426 | } // need to set address, left and right. |
| 427 | |
| 428 | currentEndNode, existingList, err := c.listFindEnd(key, side) |
| 429 | if err != nil { |
| 430 | return |
| 431 | } |
| 432 | |
| 433 | if !existingList && flags != nil && flags.has(IfAlreadyExists) { |
| 434 | return actions, nil |
| 435 | } |
| 436 | |
| 437 | if existingList { |
| 438 | node.address = ulid.MustNew(ulid.Now(), rand.Reader).String() |
| 439 | node.setNext(side, currentEndNode.address) |
| 440 | node.setPrev(side, listNull) |
| 441 | |
| 442 | actions = append(actions, currentEndNode.updateSideAction(side, node.address, c)) |
| 443 | } else { |
| 444 | // start the list with a constant address - this prevents multiple calls from overwriting it |
| 445 | node.address = key |
| 446 | node.left = listNull |
| 447 | node.right = listNull |
| 448 | } |
| 449 | |
| 450 | actions = append(actions, node.putAction(c)) |
| 451 | |
| 452 | actions = append(actions, c.listCountDeltaAction(key, 1)) |
| 453 | |
| 454 | return |
| 455 | } |
| 456 | |
| 457 | func (c Client) listCountDeltaAction(key string, delta int64) dynamodb.TransactWriteItem { |
| 458 | return dynamodb.TransactWriteItem{ |
no test coverage detected