AWS SDK for Go (PILOT)
API Reference

PREVIEW DOCUMENTATION - This is a preview of a new format for the AWS SDK for Go API Reference documentation. For the current AWS SDK for Go API Reference, see https://docs.aws.amazon.com/sdk-for-go/api/.

We welcome your feedback on this new version of the documentation. Send your comments to aws-sdkdocs-feedback@amazon.com.

UpdateBuilder

import "github.com/aws/aws-sdk-go/service/dynamodb/expression"

type UpdateBuilder struct { }

UpdateBuilder represents Update Expressions in DynamoDB. UpdateBuilders are the building blocks of the Builder struct. Note that there are different update operations in DynamoDB and an UpdateBuilder can represent multiple update operations. More Information at: https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.UpdateExpressions.html

Method

Add

func (ub UpdateBuilder) Add(name NameBuilder, value ValueBuilder) UpdateBuilder

Add adds an Add operation to the argument UpdateBuilder. The argument name should specify the item attribute and the argument value should specify the value to be added. The resulting UpdateBuilder can be used as an argument to the WithUpdate() method for the Builder struct.

Example:

// Let update represent an already existing update expression. Add() adds // the operation to add the value 5 to the item attribute "aPath" update := update.Add(expression.Name("aPath"), expression.Value(5)) // Adding more update methods anotherUpdate := update.Remove(expression.Name("someName")) // Creating a Builder builder := Update(update)

Expression Equivalent:

Add(expression.Name("aPath"), expression.Value(5)) // Let :five be an ExpressionAttributeValue representing the value 5 "ADD aPath :5"

Delete

func (ub UpdateBuilder) Delete(name NameBuilder, value ValueBuilder) UpdateBuilder

Delete adds a Delete operation to the argument UpdateBuilder. The argument name should specify the item attribute and the argument value should specify the value to be deleted. The resulting UpdateBuilder can be used as an argument to the WithUpdate() method for the Builder struct.

Example:

// Let update represent an already existing update expression. Delete() // adds the operation to delete the value "subsetToDelete" from the item // attribute "pathToList" update := update.Delete(expression.Name("pathToList"), expression.Value("subsetToDelete")) // Adding more update methods anotherUpdate := update.Remove(expression.Name("someName")) // Creating a Builder builder := Update(update)

Expression Equivalent:

Delete(expression.Name("pathToList"), expression.Value("subsetToDelete")) // let :del be an ExpressionAttributeValue representing the value // "subsetToDelete" "DELETE pathToList :del"

Remove

func (ub UpdateBuilder) Remove(name NameBuilder) UpdateBuilder

Remove adds a Remove operation to the argument UpdateBuilder. The argument name should specify the item attribute to delete. The resulting UpdateBuilder can be used as an argument to the WithUpdate() method for the Builder struct.

Example:

// Let update represent an already existing update expression. Remove() // adds the operation to remove the item attribute "itemToRemove" update := update.Remove(expression.Name("itemToRemove")) // Adding more update methods anotherUpdate := update.Remove(expression.Name("someName")) // Creating a Builder builder := Update(update)

Expression Equivalent:

Remove(expression.Name("itemToRemove")) "REMOVE itemToRemove"

Set

func (ub UpdateBuilder) Set(name NameBuilder, operandBuilder OperandBuilder) UpdateBuilder

Set adds a Set operation to the argument UpdateBuilder. The argument name should specify the item attribute to modify. The argument OperandBuilder should specify the value to modify the the item attribute to. The resulting UpdateBuilder can be used as an argument to the WithUpdate() method for the Builder struct.

Example:

// Let update represent an already existing update expression. Set() adds // the operation to to set the item attribute "itemToSet" to the value // "setValue" if the item attribute does not exist yet. (conditional // write) update := update.Set(expression.Name("itemToSet"), expression.IfNotExists(expression.Name("itemToSet"), expression.Value("setValue"))) // Adding more update methods anotherUpdate := update.Remove(expression.Name("someName")) // Creating a Builder builder := Update(update)

Expression Equivalent:

Set(expression.Name("itemToSet"), expression.IfNotExists(expression.Name("itemToSet"), expression.Value("setValue"))) // Let :val be an ExpressionAttributeValue representing the value // "setValue" "SET itemToSet = :val"

On this page: