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.

KeyBuilder

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

type KeyBuilder struct { }

KeyBuilder represents either the partition key or the sort key, both of which are top level attributes to some item in DynamoDB. Since KeyBuilder represents an operand, KeyBuilder implements the OperandBuilder interface. Methods and functions in the package take KeyBuilder as an argument and establishes relationships between operands. However, KeyBuilder should only be used to describe Key Condition Expressions. KeyBuilder should only be initialized using the function Key().

Example:

// Create a KeyBuilder representing the item key "aKey" keyBuilder := expression.Key("aKey")

Method

BeginsWith

func (kb KeyBuilder) BeginsWith(prefix string) KeyConditionBuilder

BeginsWith returns a KeyConditionBuilder representing the result of the begins_with function in DynamoDB Key Condition Expressions. The resulting KeyConditionBuilder can be used as a part of other Key Condition Expressions.

Example:

// keyCondition represents the boolean key condition of whether the value // of the key "foo" is begins with the prefix "bar" keyCondition := expression.Key("foo").BeginsWith("bar") // Used in another Key Condition Expression anotherKeyCondition := expression.Key("partitionKey").Equal(expression.Value("aValue")).And(keyCondition)

Expression Equivalent:

expression.Key("foo").BeginsWith("bar") // Let :bar be an ExpressionAttributeValue representing the value "bar" "begins_with(foo, :bar)"

Between

func (kb KeyBuilder) Between(lower, upper ValueBuilder) KeyConditionBuilder

Between returns a KeyConditionBuilder representing the result of the BETWEEN function in DynamoDB Key Condition Expressions. The resulting KeyConditionBuilder can be used as a part of other Key Condition Expressions.

Example:

// keyCondition represents the boolean key condition of whether the value // of the key "foo" is between values 5 and 10 keyCondition := expression.Key("foo").Between(expression.Value(5), expression.Value(10)) // Used in another Key Condition Expression anotherKeyCondition := expression.Key("partitionKey").Equal(expression.Value("aValue")).And(keyCondition)

Expression Equivalent:

expression.Key("foo").Between(expression.Value(5), expression.Value(10)) // Let :five and :ten be ExpressionAttributeValues representing the // values 5 and 10 respectively "foo BETWEEN :five AND :ten"

BuildOperand

func (kb KeyBuilder) 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

Equal

func (kb KeyBuilder) Equal(valueBuilder ValueBuilder) KeyConditionBuilder

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

Example:

// keyCondition represents the equal clause of the key "foo" and the // value 5 keyCondition := expression.Key("foo").Equal(expression.Value(5)) // Used in another Key Condition Expression anotherKeyCondition := expression.Key("partitionKey").Equal(expression.Value("aValue")).And(keyCondition) // Used to make an Builder builder := expression.NewBuilder().WithKeyCondition(keyCondition)

Expression Equivalent:

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

GreaterThan

func (kb KeyBuilder) GreaterThan(valueBuilder ValueBuilder) KeyConditionBuilder

GreaterThan returns a KeyConditionBuilder representing the greater than clause of the two argument OperandBuilders. The resulting KeyConditionBuilder can be used as a part of other Key Condition Expressions.

Example:

// key condition represents the greater than clause of the key "foo" and // the value 5 keyCondition := expression.Key("foo").GreaterThan(expression.Value(5)) // Used in another Key Condition Expression anotherKeyCondition := expression.Key("partitionKey").Equal(expression.Value("aValue")).And(keyCondition)

Expression Equivalent:

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

GreaterThanEqual

func (kb KeyBuilder) GreaterThanEqual(valueBuilder ValueBuilder) KeyConditionBuilder

GreaterThanEqual returns a KeyConditionBuilder representing the greater than equal to clause of the two argument OperandBuilders. The resulting KeyConditionBuilder can be used as a part of other Key Condition Expressions.

Example:

// keyCondition represents the greater than equal to clause of the key // "foo" and the value 5 keyCondition := expression.Key("foo").GreaterThanEqual(expression.Value(5)) // Used in another Key Condition Expression anotherKeyCondition := expression.Key("partitionKey").Equal(expression.Value("aValue")).And(keyCondition)

Expression Equivalent:

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

LessThan

func (kb KeyBuilder) LessThan(valueBuilder ValueBuilder) KeyConditionBuilder

LessThan returns a KeyConditionBuilder representing the less than clause of the two argument OperandBuilders. The resulting KeyConditionBuilder can be used as a part of other Key Condition Expressions.

Example:

// keyCondition represents the less than clause of the key "foo" and the // value 5 keyCondition := expression.Key("foo").LessThan(expression.Value(5)) // Used in another Key Condition Expression anotherKeyCondition := expression.Key("partitionKey").Equal(expression.Value("aValue")).And(keyCondition)

Expression Equivalent:

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

LessThanEqual

func (kb KeyBuilder) LessThanEqual(valueBuilder ValueBuilder) KeyConditionBuilder

LessThanEqual returns a KeyConditionBuilder representing the less than equal to clause of the two argument OperandBuilders. The resulting KeyConditionBuilder can be used as a part of other Key Condition Expressions.

Example:

// keyCondition represents the less than equal to clause of the key // "foo" and the value 5 keyCondition := expression.Key("foo").LessThanEqual(expression.Value(5)) // Used in another Key Condition Expression anotherKeyCondition := expression.Key("partitionKey").Equal(expression.Value("aValue")).And(keyCondition)

Expression Equivalent:

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

On this page: