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.

NameBuilder

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

type NameBuilder struct { }

NameBuilder represents a name of a top level item attribute or a nested attribute. Since NameBuilder represents a DynamoDB Operand, it implements the OperandBuilder interface. Methods and functions in the package take NameBuilder as an argument and establishes relationships between operands. NameBuilder should only be initialized using the function Name().

Example:

// Create a NameBuilder representing the item attribute "aName" nameBuilder := expression.Name("aName")

Method

AttributeExists

func (nb NameBuilder) AttributeExists() ConditionBuilder

AttributeExists returns a ConditionBuilder representing the result of the attribute_exists function in DynamoDB Condition Expressions. The resulting ConditionBuilder can be used as a part of other Condition Expressions or as an argument to the WithCondition() method for the Builder struct.

Example:

// condition represents the boolean condition of whether the item // attribute "Age" exists or not condition := expression.Name("Age").AttributeExists() // Used in another Condition Expression anotherCondition := expression.Not(condition) // Used to make an Builder builder := expression.NewBuilder().WithCondition(condition)

Expression Equivalent:

expression.Name("Age").AttributeExists() "attribute_exists (Age))"

AttributeNotExists

func (nb NameBuilder) AttributeNotExists() ConditionBuilder

AttributeNotExists returns a ConditionBuilder representing the result of the attribute_not_exists function in DynamoDB Condition Expressions. The resulting ConditionBuilder can be used as a part of other Condition Expressions or as an argument to the WithCondition() method for the Builder struct.

Example:

// condition represents the boolean condition of whether the item // attribute "Age" exists or not condition := expression.Name("Age").AttributeNotExists() // Used in another Condition Expression anotherCondition := expression.Not(condition) // Used to make an Builder builder := expression.NewBuilder().WithCondition(condition)

Expression Equivalent:

expression.Name("Age").AttributeNotExists() "attribute_not_exists (Age))"

AttributeType

func (nb NameBuilder) AttributeType(attributeType DynamoDBAttributeType) ConditionBuilder

AttributeType returns a ConditionBuilder representing the result of the attribute_type function in DynamoDB Condition Expressions. The DynamoDB types are represented by the type DynamoDBAttributeType. The resulting ConditionBuilder can be used as a part of other Condition Expressions or as an argument to the WithCondition() method for the Builder struct.

Example:

// condition represents the boolean condition of whether the item // attribute "Age" has the DynamoDB type Number or not condition := expression.Name("Age").AttributeType(expression.Number) // Used in another Condition Expression anotherCondition := expression.Not(condition) // Used to make an Builder builder := expression.NewBuilder().WithCondition(condition)

Expression Equivalent:

expression.Name("Age").AttributeType(expression.Number) // Let :type be an ExpressionAttributeValue representing the value "N" "attribute_type (Age, :type)"

BeginsWith

func (nb NameBuilder) BeginsWith(prefix string) ConditionBuilder

BeginsWith returns a ConditionBuilder representing the result of the begins_with function in DynamoDB Condition Expressions. The resulting ConditionBuilder can be used as a part of other Condition Expressions or as an argument to the WithCondition() method for the Builder struct.

Example:

// condition represents the boolean condition of whether the item // attribute "CodeName" starts with the substring "Ben" condition := expression.Name("CodeName").BeginsWith("Ben") // Used in another Condition Expression anotherCondition := expression.Not(condition) // Used to make an Builder builder := expression.NewBuilder().WithCondition(condition)

Expression Equivalent:

expression.Name("CodeName").BeginsWith("Ben") // Let :ben be an ExpressionAttributeValue representing the value "Ben" "begins_with (CodeName, :ben)"

Between

func (nb NameBuilder) Between(lower, upper OperandBuilder) ConditionBuilder

Between returns a ConditionBuilder representing the result of the BETWEEN function in DynamoDB Condition Expressions. The resulting ConditionBuilder can be used as a part of other Condition Expressions or as an argument to the WithCondition() method for the Builder struct.

Example:

// condition represents the condition where the value of the item // attribute "Rating" is between values 5 and 10 condition := expression.Name("Rating").Between(expression.Value(5), expression.Value(10)) // Used in another Condition Expression anotherCondition := expression.Not(condition) // Used to make an Builder builder := expression.NewBuilder().WithCondition(condition)

Expression Equivalent:

expression.Name("Rating").Between(expression.Value(5), expression.Value(10)) // Let :five and :ten be ExpressionAttributeValues representing the value // 5 and the value 10 "Rating BETWEEN :five AND :ten"

BuildOperand

func (nb NameBuilder) BuildOperand() (Operand, error)

BuildOperand creates an Operand struct which are building blocks to DynamoDB Expressions. Package methods and functions can establish relationships between operands, representing DynamoDB Expressions. The method BuildOperand() is called recursively when the Build() method on the type Builder is called. BuildOperand() should never be called externally. BuildOperand() aliases all strings to avoid stepping over DynamoDB's reserved words. More information on reserved words at https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ReservedWords.html

Contains

func (nb NameBuilder) Contains(substr string) ConditionBuilder

Contains returns a ConditionBuilder representing the result of the contains function in DynamoDB Condition Expressions. The resulting ConditionBuilder can be used as a part of other Condition Expressions or as an argument to the WithCondition() method for the Builder struct.

Example:

// condition represents the boolean condition of whether the item // attribute "InviteList" has the value "Ben" condition := expression.Name("InviteList").Contains(expression.Value("Ben")) // Used in another Condition Expression anotherCondition := expression.Not(condition) // Used to make an Builder builder := expression.NewBuilder().WithCondition(condition)

Expression Equivalent:

expression.Name("InviteList").Contains(expression.Value("Ben")) // Let :ben be an ExpressionAttributeValue representing the value "Ben" "contains (InviteList, :ben)"

Equal

func (nb NameBuilder) Equal(right OperandBuilder) ConditionBuilder

Equal returns a ConditionBuilder representing the equality clause of the two argument OperandBuilders. The resulting ConditionBuilder can be used as a part of other Condition Expressions or as an argument to the WithCondition() method for the Builder struct.

Example:

// condition represents the equal clause of the item attribute "foo" and // the value 5 condition := expression.Name("foo").Equal(expression.Value(5)) // Used in another Condition Expression anotherCondition := expression.Not(condition) // Used to make an Builder builder := expression.NewBuilder().WithCondition(condition)

Expression Equivalent:

expression.Name("foo").Equal(expression.Value(5)) // Let :five be an ExpressionAttributeValue representing the value 5 "foo = :five"

GreaterThan

func (nb NameBuilder) GreaterThan(right OperandBuilder) ConditionBuilder

GreaterThan returns a ConditionBuilder representing the greater than clause of the two argument OperandBuilders. The resulting ConditionBuilder can be used as a part of other Condition Expressions or as an argument to the WithCondition() method for the Builder struct.

Example:

// condition represents the greater than clause of the item attribute // "foo" and the value 5 condition := expression.Name("foo").GreaterThan(expression.Value(5)) // Used in another Condition Expression anotherCondition := expression.Not(condition) // Used to make an Builder builder := expression.NewBuilder().WithCondition(condition)

Expression Equivalent:

expression.Name("foo").GreaterThan(expression.Value(5)) // Let :five be an ExpressionAttributeValue representing the value 5 "foo > :five"

GreaterThanEqual

func (nb NameBuilder) GreaterThanEqual(right OperandBuilder) ConditionBuilder

GreaterThanEqual returns a ConditionBuilder representing the greater than equal to clause of the two argument OperandBuilders. The resulting ConditionBuilder can be used as a part of other Condition Expressions or as an argument to the WithCondition() method for the Builder struct.

Example:

// condition represents the greater than equal to clause of the item // attribute "foo" and the value 5 condition := expression.Name("foo").GreaterThanEqual(expression.Value(5)) // Used in another Condition Expression anotherCondition := expression.Not(condition) // Used to make an Builder builder := expression.NewBuilder().WithCondition(condition)

Expression Equivalent:

expression.Name("foo").GreaterThanEqual(expression.Value(5)) // Let :five be an ExpressionAttributeValue representing the value 5 "foo >= :five"

IfNotExists

func (nb NameBuilder) IfNotExists(rightOperand OperandBuilder) SetValueBuilder

IfNotExists creates a SetValueBuilder to be used in as an argument to Set(). The first argument must be a NameBuilder representing the name where the new item attribute is created. The second argument can either be a NameBuilder or a ValueBuilder. In the case that it is a NameBuilder, the value of the item attribute at the name specified becomes the value of the new item attribute. More information: https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.UpdateExpressions.html#Expressions.UpdateExpressions.SET.PreventingAttributeOverwrites

Example:

// Use IfNotExists() to set item attribute "someName" to value 5 if // "someName" does not exist yet. (Prevents overwrite) update, err := expression.Set(expression.Name("someName"), expression.Name("someName").IfNotExists(expression.Value(5)))

Expression Equivalent:

expression.Name("someName").IfNotExists(expression.Value(5)) // let :five be a ExpressionAttributeValue representing the value 5 "if_not_exists (someName, :five)"

In

func (nb NameBuilder) In(right OperandBuilder, other ...OperandBuilder) ConditionBuilder

In returns a ConditionBuilder representing the result of the IN function in DynamoDB Condition Expressions. The resulting ConditionBuilder can be used as a part of other Condition Expressions or as an argument to the WithCondition() method for the Builder struct.

Example:

// condition represents the condition where the value of the item // attribute "Color" is checked against the list of colors "red", // "green", and "blue". condition := expression.Name("Color").In(expression.Value("red"), expression.Value("green"), expression.Value("blue")) // Used in another Condition Expression anotherCondition := expression.Not(condition) // Used to make an Builder builder := expression.NewBuilder().WithCondition(condition)

Expression Equivalent:

expression.Name("Color").In(expression.Value("red"), expression.Value("green"), expression.Value("blue")) // Let :red, :green, :blue be ExpressionAttributeValues representing the // values "red", "green", and "blue" respectively "Color IN (:red, :green, :blue)"

LessThan

func (nb NameBuilder) LessThan(right OperandBuilder) ConditionBuilder

LessThan returns a ConditionBuilder representing the less than clause of the two argument OperandBuilders. The resulting ConditionBuilder can be used as a part of other Condition Expressions or as an argument to the WithCondition() method for the Builder struct.

Example:

// condition represents the less than clause of the item attribute "foo" // and the value 5 condition := expression.Name("foo").LessThan(expression.Value(5)) // Used in another Condition Expression anotherCondition := expression.Not(condition) // Used to make an Builder builder := expression.NewBuilder().WithCondition(condition)

Expression Equivalent:

expression.Name("foo").LessThan(expression.Value(5)) // Let :five be an ExpressionAttributeValue representing the value 5 "foo < :five"

LessThanEqual

func (nb NameBuilder) LessThanEqual(right OperandBuilder) ConditionBuilder

LessThanEqual returns a ConditionBuilder representing the less than equal to clause of the two argument OperandBuilders. The resulting ConditionBuilder can be used as a part of other Condition Expressions or as an argument to the WithCondition() method for the Builder struct.

Example:

// condition represents the less than equal to clause of the item // attribute "foo" and the value 5 condition := expression.Name("foo").LessThanEqual(expression.Value(5)) // Used in another Condition Expression anotherCondition := expression.Not(condition) // Used to make an Builder builder := expression.NewBuilder().WithCondition(condition)

Expression Equivalent:

expression.Name("foo").LessThanEqual(expression.Value(5)) // Let :five be an ExpressionAttributeValue representing the value 5 "foo <= :five"

ListAppend

func (nb NameBuilder) ListAppend(rightOperand OperandBuilder) SetValueBuilder

ListAppend creates a SetValueBuilder to be used in as an argument to Set(). The arguments can either be NameBuilders or ValueBuilders. ListAppend() only supports DynamoDB List types, so the ValueBuilder must be a List and the NameBuilder must specify an item attribute of type List. More information: https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.UpdateExpressions.html#Expressions.UpdateExpressions.SET.UpdatingListElements

Example:

// Use ListAppend() to set item attribute "someName" to the item // attribute "nameOfList" with "some" and "list" appended to it update, err := expression.Set(expression.Name("someName"), expression.Name("nameOfList").ListAppend(expression.Value([]string{"some", "list"})))

Expression Equivalent:

expression.Name("nameOfList").ListAppend(expression.Value([]string{"some", "list"}) // let :list be a ExpressionAttributeValue representing the list // containing "some" and "list". "list_append (nameOfList, :list)"

Minus

func (nb NameBuilder) Minus(rightOperand OperandBuilder) SetValueBuilder

Minus creates a SetValueBuilder to be used in as an argument to Set(). The arguments can either be NameBuilders or ValueBuilders. Minus() only supports DynamoDB Number types, so the ValueBuilder must be a Number and the NameBuilder must specify an item attribute of type Number. More information: https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.UpdateExpressions.html#Expressions.UpdateExpressions.SET.IncrementAndDecrement

Example:

// Use Minus() to set the value of item attribute "someName" to the // numeric value of "aName" decremented by 10 update, err := expression.Set(expression.Name("someName"), expression.Name("aName").Minus(expression.Value(10)))

Expression Equivalent:

expression.Name("aName").Minus(expression.Value(10))) // let :ten be ExpressionAttributeValues represent the value 10 "aName - :ten"

NamesList

func (nb NameBuilder) NamesList(namesList ...NameBuilder) ProjectionBuilder

NamesList returns a ProjectionBuilder representing the list of item attribute names specified by the argument NameBuilders. The resulting ProjectionBuilder can be used as a part of other ProjectionBuilders or as an argument to the WithProjection() method for the Builder struct.

Example:

// projection represents the list of names {"foo", "bar"} projection := expression.Name("foo").NamesList(expression.Name("bar")) // Used in another Projection Expression anotherProjection := expression.AddNames(projection, expression.Name("baz")) // Used to make an Builder builder := expression.NewBuilder().WithProjection(newProjection)

Expression Equivalent:

expression.Name("foo").NamesList(expression.Name("bar")) "foo, bar"

NotEqual

func (nb NameBuilder) NotEqual(right OperandBuilder) ConditionBuilder

NotEqual returns a ConditionBuilder representing the not equal clause of the two argument OperandBuilders. The resulting ConditionBuilder can be used as a part of other Condition Expressions or as an argument to the WithCondition() method for the Builder struct.

Example:

// condition represents the not equal clause of the item attribute "foo" // and the value 5 condition := expression.Name("foo").NotEqual(expression.Value(5)) // Used in another Condition Expression anotherCondition := expression.Not(condition) // Used to make an Builder builder := expression.NewBuilder().WithCondition(condition)

Expression Equivalent:

expression.Name("foo").NotEqual(expression.Value(5)) // Let :five be an ExpressionAttributeValue representing the value 5 "foo <> :five"

Plus

func (nb NameBuilder) Plus(rightOperand OperandBuilder) SetValueBuilder

Plus creates a SetValueBuilder to be used in as an argument to Set(). The arguments can either be NameBuilders or ValueBuilders. Plus() only supports DynamoDB Number types, so the ValueBuilder must be a Number and the NameBuilder must specify an item attribute of type Number. More information: https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.UpdateExpressions.html#Expressions.UpdateExpressions.SET.IncrementAndDecrement

Example:

// Use Plus() to set the value of the item attribute "someName" to the // numeric value of item attribute "aName" incremented by 10 update, err := expression.Set(expression.Name("someName"), expression.Name("aName").Plus(expression.Value(10)))

Expression Equivalent:

expression.Name("aName").Plus(expression.Value(10)) // let :ten be ExpressionAttributeValues representing the value 10 "aName + :ten"

Size

func (nb NameBuilder) Size() SizeBuilder

Size creates a SizeBuilder representing the size of the item attribute specified by the argument NameBuilder. Size() is only valid for certain types of item attributes. For documentation, see: https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html SizeBuilder is only a valid operand in Condition Expressions and Filter Expressions.

Example:

// Use Size() to create a condition expression condition := expression.Name("foo").Size().Equal(expression.Value(10))

Expression Equivalent:

expression.Name("aName").Size() "size (aName)"

On this page: