expression

package
v1.13.29 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 5, 2018 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package expression provides types and functions to create Amazon DynamoDB Expression strings, ExpressionAttributeNames maps, and ExpressionAttributeValues maps.

Using the Package

The package represents the various DynamoDB Expressions as structs named accordingly. For example, ConditionBuilder represents a DynamoDB Condition Expression, an UpdateBuilder represents a DynamoDB Update Expression, and so on. The following example shows a sample ConditionExpression and how to build an equilvalent ConditionBuilder

// Let :a be an ExpressionAttributeValue representing the string "No One You
// Know"
condExpr := "Artist = :a"
condBuilder := expression.Name("Artist").Equal(expression.Value("No One You Know"))

In order to retrieve the formatted DynamoDB Expression strings, call the getter methods on the Expression struct. To create the Expression struct, call the Build() method on the Builder struct. Because some input structs, such as QueryInput, can have multiple DynamoDB Expressions, multiple structs representing various DynamoDB Expressions can be added to the Builder struct. The following example shows a generic usage of the whole package.

filt := expression.Name("Artist").Equal(expression.Value("No One You Know"))
proj := expression.NamesList(expression.Name("SongTitle"), expression.Name("AlbumTitle"))
expr, err := expression.NewBuilder().WithFilter(filt).WithProjection(proj).Build()
if err != nil {
  fmt.Println(err)
}

input := &dynamodb.ScanInput{
  ExpressionAttributeNames:  expr.Names(),
  ExpressionAttributeValues: expr.Values(),
  FilterExpression:          expr.Filter(),
  ProjectionExpression:      expr.Projection(),
  TableName:                 aws.String("Music"),
}

The ExpressionAttributeNames and ExpressionAttributeValues member of the input struct must always be assigned when using the Expression struct because all item attribute names and values are aliased. That means that if the ExpressionAttributeNames and ExpressionAttributeValues member is not assigned with the corresponding Names() and Values() methods, the DynamoDB operation will run into a logic error.

Index

Examples

Constants

View Source
const (
	// String represents the DynamoDB String type
	String DynamoDBAttributeType = "S"
	// StringSet represents the DynamoDB String Set type
	StringSet = "SS"
	// Number represents the DynamoDB Number type
	Number = "N"
	// NumberSet represents the DynamoDB Number Set type
	NumberSet = "NS"
	// Binary represents the DynamoDB Binary type
	Binary = "B"
	// BinarySet represents the DynamoDB Binary Set type
	BinarySet = "BS"
	// Boolean represents the DynamoDB Boolean type
	Boolean = "BOOL"
	// Null represents the DynamoDB Null type
	Null = "NULL"
	// List represents the DynamoDB List type
	List = "L"
	// Map represents the DynamoDB Map type
	Map = "M"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Builder

type Builder struct {
	// contains filtered or unexported fields
}

Builder represents the struct that builds the Expression struct. Methods such as WithProjection() and WithCondition() can add different kinds of DynamoDB Expressions to the Builder. The method Build() creates an Expression struct with the specified types of DynamoDB Expressions.

Example:

keyCond := expression.Key("someKey").Equal(expression.Value("someValue"))
proj := expression.NamesList(expression.Name("aName"), expression.Name("anotherName"), expression.Name("oneOtherName"))

builder := expression.NewBuilder().WithKeyCondition(keyCond).WithProjection(proj)
expression := builder.Build()

queryInput := dynamodb.QueryInput{
  KeyConditionExpression:    expression.KeyCondition(),
  ProjectionExpression:      expression.Projection(),
  ExpressionAttributeNames:  expression.Names(),
  ExpressionAttributeValues: expression.Values(),
  TableName: aws.String("SomeTable"),
}

func NewBuilder

func NewBuilder() Builder

NewBuilder returns an empty Builder struct. Methods such as WithProjection() and WithCondition() can add different kinds of DynamoDB Expressions to the Builder. The method Build() creates an Expression struct with the specified types of DynamoDB Expressions.

Example:

keyCond := expression.Key("someKey").Equal(expression.Value("someValue"))
proj := expression.NamesList(expression.Name("aName"), expression.Name("anotherName"), expression.Name("oneOtherName"))
builder := expression.NewBuilder().WithKeyCondition(keyCond).WithProjection(proj)

func (Builder) Build

func (b Builder) Build() (Expression, error)

Build builds an Expression struct representing multiple types of DynamoDB Expressions. Getter methods on the resulting Expression struct returns the DynamoDB Expression strings as well as the maps that correspond to ExpressionAttributeNames and ExpressionAttributeValues. Calling Build() on an empty Builder returns the typed error EmptyParameterError.

Example:

// keyCond represents the Key Condition Expression
keyCond := expression.Key("someKey").Equal(expression.Value("someValue"))
// proj represents the Projection Expression
proj := expression.NamesList(expression.Name("aName"), expression.Name("anotherName"), expression.Name("oneOtherName"))

// Add keyCond and proj to builder as a Key Condition and Projection
// respectively
builder := expression.NewBuilder().WithKeyCondition(keyCond).WithProjection(proj)
expression := builder.Build()

queryInput := dynamodb.QueryInput{
  KeyConditionExpression:    expression.KeyCondition(),
  ProjectionExpression:      expression.Projection(),
  ExpressionAttributeNames:  expression.Names(),
  ExpressionAttributeValues: expression.Values(),
  TableName: aws.String("SomeTable"),
}

func (Builder) WithCondition

func (b Builder) WithCondition(conditionBuilder ConditionBuilder) Builder

WithCondition method adds the argument ConditionBuilder as a Condition Expression to the argument Builder. If the argument Builder already has a ConditionBuilder representing a Condition Expression, WithCondition() overwrites the existing ConditionBuilder.

Example:

// let builder be an existing Builder{} and cond be an existing
// ConditionBuilder{}
builder = builder.WithCondition(cond)

// add other DynamoDB Expressions to the builder. let proj be an already
// existing ProjectionBuilder
builder = builder.WithProjection(proj)
// create an Expression struct
expression := builder.Build()
Example

Using Condition Expression

This example deletes an item from the Music table if the rating is lower than 7.

package main

import (
	"fmt"

	"github.com/aws/aws-sdk-go/aws"
	"github.com/aws/aws-sdk-go/aws/awserr"
	"github.com/aws/aws-sdk-go/aws/session"
	"github.com/aws/aws-sdk-go/service/dynamodb"
	"github.com/aws/aws-sdk-go/service/dynamodb/expression"
)

func main() {
	svc := dynamodb.New(session.New())

	// Create a condition where the Rating field must be less than 7.
	cond := expression.Name("Rating").LessThan(expression.Value(7))

	// Create a DynamoDB expression from the condition.
	expr, err := expression.NewBuilder().
		WithCondition(cond).
		Build()
	if err != nil {
		fmt.Println(err)
	}

	// Use the built expression to populate the DeleteItem API operation with the
	// condition expression.
	input := &dynamodb.DeleteItemInput{
		Key: map[string]*dynamodb.AttributeValue{
			"Artist": {
				S: aws.String("No One You Know"),
			},
			"SongTitle": {
				S: aws.String("Scared of My Shadow"),
			},
		},
		ExpressionAttributeNames:  expr.Names(),
		ExpressionAttributeValues: expr.Values(),
		ConditionExpression:       expr.Condition(),
		TableName:                 aws.String("Music"),
	}

	result, err := svc.DeleteItem(input)
	if err != nil {
		if aerr, ok := err.(awserr.Error); ok {
			switch aerr.Code() {
			case dynamodb.ErrCodeConditionalCheckFailedException:
				fmt.Println(dynamodb.ErrCodeConditionalCheckFailedException, aerr.Error())
			case dynamodb.ErrCodeProvisionedThroughputExceededException:
				fmt.Println(dynamodb.ErrCodeProvisionedThroughputExceededException, aerr.Error())
			case dynamodb.ErrCodeResourceNotFoundException:
				fmt.Println(dynamodb.ErrCodeResourceNotFoundException, aerr.Error())
			case dynamodb.ErrCodeItemCollectionSizeLimitExceededException:
				fmt.Println(dynamodb.ErrCodeItemCollectionSizeLimitExceededException, aerr.Error())
			case dynamodb.ErrCodeInternalServerError:
				fmt.Println(dynamodb.ErrCodeInternalServerError, aerr.Error())
			default:
				fmt.Println(aerr.Error())
			}
		} else {
			// Print the error, cast err to awserr.Error to get the Code and
			// Message from an error.
			fmt.Println(err.Error())
		}
		return
	}

	fmt.Println(result)
}
Output:

func (Builder) WithFilter

func (b Builder) WithFilter(filterBuilder ConditionBuilder) Builder

WithFilter method adds the argument ConditionBuilder as a Filter Expression to the argument Builder. If the argument Builder already has a ConditionBuilder representing a Filter Expression, WithFilter() overwrites the existing ConditionBuilder.

Example:

// let builder be an existing Builder{} and filt be an existing
// ConditionBuilder{}
builder = builder.WithFilter(filt)

// add other DynamoDB Expressions to the builder. let cond be an already
// existing ConditionBuilder
builder = builder.WithCondition(cond)
// create an Expression struct
expression := builder.Build()
Example

Using Filter Expression

This example scans the entire Music table, and then narrows the results to songs by the artist "No One You Know". For each item, only the album title and song title are returned.

package main

import (
	"fmt"

	"github.com/aws/aws-sdk-go/aws"
	"github.com/aws/aws-sdk-go/aws/awserr"
	"github.com/aws/aws-sdk-go/aws/session"
	"github.com/aws/aws-sdk-go/service/dynamodb"
	"github.com/aws/aws-sdk-go/service/dynamodb/expression"
)

func main() {
	svc := dynamodb.New(session.New())

	// Construct the filter builder with a name and value.
	filt := expression.Name("Artist").Equal(expression.Value("No One You Know"))

	// Create the names list projection of names to project.
	proj := expression.NamesList(
		expression.Name("AlbumTitle"),
		expression.Name("SongTitle"),
	)

	// Using the filter and projections create a DynamoDB expression from the two.
	expr, err := expression.NewBuilder().
		WithFilter(filt).
		WithProjection(proj).
		Build()
	if err != nil {
		fmt.Println(err)
	}

	// Use the built expression to populate the DynamoDB Scan API input parameters.
	input := &dynamodb.ScanInput{
		ExpressionAttributeNames:  expr.Names(),
		ExpressionAttributeValues: expr.Values(),
		FilterExpression:          expr.Filter(),
		ProjectionExpression:      expr.Projection(),
		TableName:                 aws.String("Music"),
	}

	result, err := svc.Scan(input)
	if err != nil {
		if aerr, ok := err.(awserr.Error); ok {
			switch aerr.Code() {
			case dynamodb.ErrCodeProvisionedThroughputExceededException:
				fmt.Println(dynamodb.ErrCodeProvisionedThroughputExceededException, aerr.Error())
			case dynamodb.ErrCodeResourceNotFoundException:
				fmt.Println(dynamodb.ErrCodeResourceNotFoundException, aerr.Error())
			case dynamodb.ErrCodeInternalServerError:
				fmt.Println(dynamodb.ErrCodeInternalServerError, aerr.Error())
			default:
				fmt.Println(aerr.Error())
			}
		} else {
			// Print the error, cast err to awserr.Error to get the Code and
			// Message from an error.
			fmt.Println(err.Error())
		}
		return
	}

	fmt.Println(result)
}
Output:

func (Builder) WithKeyCondition

func (b Builder) WithKeyCondition(keyConditionBuilder KeyConditionBuilder) Builder

WithKeyCondition method adds the argument KeyConditionBuilder as a Key Condition Expression to the argument Builder. If the argument Builder already has a KeyConditionBuilder representing a Key Condition Expression, WithKeyCondition() overwrites the existing KeyConditionBuilder.

Example:

// let builder be an existing Builder{} and keyCond be an existing
// KeyConditionBuilder{}
builder = builder.WithKeyCondition(keyCond)

// add other DynamoDB Expressions to the builder. let cond be an already
// existing ConditionBuilder
builder = builder.WithCondition(cond)
// create an Expression struct
expression := builder.Build()
Example

Using Key Condition Expression

This example queries items in the Music table. The table has a partition key and sort key (Artist and SongTitle), but this query only specifies the partition key value. It returns song titles by the artist named "No One You Know".

package main

import (
	"fmt"

	"github.com/aws/aws-sdk-go/aws"
	"github.com/aws/aws-sdk-go/aws/awserr"
	"github.com/aws/aws-sdk-go/aws/session"
	"github.com/aws/aws-sdk-go/service/dynamodb"
	"github.com/aws/aws-sdk-go/service/dynamodb/expression"
)

func main() {
	svc := dynamodb.New(session.New())

	// Construct the Key condition builder
	keyCond := expression.Key("Artist").Equal(expression.Value("No One You Know"))

	// Create the project expression builder with a names list.
	proj := expression.NamesList(expression.Name("SongTitle"))

	// Combine the key condition, and projection together as a DynamoDB expression
	// builder.
	expr, err := expression.NewBuilder().
		WithKeyCondition(keyCond).
		WithProjection(proj).
		Build()
	if err != nil {
		fmt.Println(err)
	}

	// Use the built expression to populate the DynamoDB Query's API input
	// parameters.
	input := &dynamodb.QueryInput{
		ExpressionAttributeValues: expr.Values(),
		KeyConditionExpression:    expr.KeyCondition(),
		ProjectionExpression:      expr.Projection(),
		TableName:                 aws.String("Music"),
	}

	result, err := svc.Query(input)
	if err != nil {
		if aerr, ok := err.(awserr.Error); ok {
			switch aerr.Code() {
			case dynamodb.ErrCodeProvisionedThroughputExceededException:
				fmt.Println(dynamodb.ErrCodeProvisionedThroughputExceededException, aerr.Error())
			case dynamodb.ErrCodeResourceNotFoundException:
				fmt.Println(dynamodb.ErrCodeResourceNotFoundException, aerr.Error())
			case dynamodb.ErrCodeInternalServerError:
				fmt.Println(dynamodb.ErrCodeInternalServerError, aerr.Error())
			default:
				fmt.Println(aerr.Error())
			}
		} else {
			// Print the error, cast err to awserr.Error to get the Code and
			// Message from an error.
			fmt.Println(err.Error())
		}
		return
	}

	fmt.Println(result)
}
Output:

func (Builder) WithProjection

func (b Builder) WithProjection(projectionBuilder ProjectionBuilder) Builder

WithProjection method adds the argument ProjectionBuilder as a Projection Expression to the argument Builder. If the argument Builder already has a ProjectionBuilder representing a Projection Expression, WithProjection() overwrites the existing ProjectionBuilder.

Example:

// let builder be an existing Builder{} and proj be an existing
// ProjectionBuilder{}
builder = builder.WithProjection(proj)

// add other DynamoDB Expressions to the builder. let cond be an already
// existing ConditionBuilder
builder = builder.WithCondition(cond)
// create an Expression struct
expression := builder.Build()
Example

Using Projection Expression

This example queries items in the Music table. The table has a partition key and sort key (Artist and SongTitle), but this query only specifies the partition key value. It returns song titles by the artist named "No One You Know".

package main

import (
	"fmt"

	"github.com/aws/aws-sdk-go/aws"
	"github.com/aws/aws-sdk-go/aws/awserr"
	"github.com/aws/aws-sdk-go/aws/session"
	"github.com/aws/aws-sdk-go/service/dynamodb"
	"github.com/aws/aws-sdk-go/service/dynamodb/expression"
)

func main() {
	svc := dynamodb.New(session.New())

	// Construct the Key condition builder
	keyCond := expression.Key("Artist").Equal(expression.Value("No One You Know"))

	// Create the project expression builder with a names list.
	proj := expression.NamesList(expression.Name("SongTitle"))

	// Combine the key condition, and projection together as a DynamoDB expression
	// builder.
	expr, err := expression.NewBuilder().
		WithKeyCondition(keyCond).
		WithProjection(proj).
		Build()
	if err != nil {
		fmt.Println(err)
	}

	// Use the built expression to populate the DynamoDB Query's API input
	// parameters.
	input := &dynamodb.QueryInput{
		ExpressionAttributeValues: expr.Values(),
		KeyConditionExpression:    expr.KeyCondition(),
		ProjectionExpression:      expr.Projection(),
		TableName:                 aws.String("Music"),
	}

	result, err := svc.Query(input)
	if err != nil {
		if aerr, ok := err.(awserr.Error); ok {
			switch aerr.Code() {
			case dynamodb.ErrCodeProvisionedThroughputExceededException:
				fmt.Println(dynamodb.ErrCodeProvisionedThroughputExceededException, aerr.Error())
			case dynamodb.ErrCodeResourceNotFoundException:
				fmt.Println(dynamodb.ErrCodeResourceNotFoundException, aerr.Error())
			case dynamodb.ErrCodeInternalServerError:
				fmt.Println(dynamodb.ErrCodeInternalServerError, aerr.Error())
			default:
				fmt.Println(aerr.Error())
			}
		} else {
			// Print the error, cast err to awserr.Error to get the Code and
			// Message from an error.
			fmt.Println(err.Error())
		}
		return
	}

	fmt.Println(result)
}
Output:

func (Builder) WithUpdate

func (b Builder) WithUpdate(updateBuilder UpdateBuilder) Builder

WithUpdate method adds the argument UpdateBuilder as an Update Expression to the argument Builder. If the argument Builder already has a UpdateBuilder representing a Update Expression, WithUpdate() overwrites the existing UpdateBuilder.

Example:

// let builder be an existing Builder{} and update be an existing
// UpdateBuilder{}
builder = builder.WithUpdate(update)

// add other DynamoDB Expressions to the builder. let cond be an already
// existing ConditionBuilder
builder = builder.WithCondition(cond)
// create an Expression struct
expression := builder.Build()
Example

Using Update Expression

This example updates an item in the Music table. It adds a new attribute (Year) and modifies the AlbumTitle attribute. All of the attributes in the item, as they appear after the update, are returned in the response.

package main

import (
	"fmt"

	"github.com/aws/aws-sdk-go/aws"
	"github.com/aws/aws-sdk-go/aws/awserr"
	"github.com/aws/aws-sdk-go/aws/session"
	"github.com/aws/aws-sdk-go/service/dynamodb"
	"github.com/aws/aws-sdk-go/service/dynamodb/expression"
)

func main() {
	svc := dynamodb.New(session.New())

	// Create an update to set two fields in the table.
	update := expression.Set(
		expression.Name("Year"),
		expression.Value(2015),
	).Set(
		expression.Name("AlbumTitle"),
		expression.Value("Louder Than Ever"),
	)

	// Create the DynamoDB expression from the Update.
	expr, err := expression.NewBuilder().
		WithUpdate(update).
		Build()

	// Use the built expression to populate the DynamoDB UpdateItem API
	// input parameters.
	input := &dynamodb.UpdateItemInput{
		ExpressionAttributeNames:  expr.Names(),
		ExpressionAttributeValues: expr.Values(),
		Key: map[string]*dynamodb.AttributeValue{
			"Artist": {
				S: aws.String("Acme Band"),
			},
			"SongTitle": {
				S: aws.String("Happy Day"),
			},
		},
		ReturnValues:     aws.String("ALL_NEW"),
		TableName:        aws.String("Music"),
		UpdateExpression: expr.Update(),
	}

	result, err := svc.UpdateItem(input)
	if err != nil {
		if aerr, ok := err.(awserr.Error); ok {
			switch aerr.Code() {
			case dynamodb.ErrCodeConditionalCheckFailedException:
				fmt.Println(dynamodb.ErrCodeConditionalCheckFailedException, aerr.Error())
			case dynamodb.ErrCodeProvisionedThroughputExceededException:
				fmt.Println(dynamodb.ErrCodeProvisionedThroughputExceededException, aerr.Error())
			case dynamodb.ErrCodeResourceNotFoundException:
				fmt.Println(dynamodb.ErrCodeResourceNotFoundException, aerr.Error())
			case dynamodb.ErrCodeItemCollectionSizeLimitExceededException:
				fmt.Println(dynamodb.ErrCodeItemCollectionSizeLimitExceededException, aerr.Error())
			case dynamodb.ErrCodeInternalServerError:
				fmt.Println(dynamodb.ErrCodeInternalServerError, aerr.Error())
			default:
				fmt.Println(aerr.Error())
			}
		} else {
			// Print the error, cast err to awserr.Error to get the Code and
			// Message from an error.
			fmt.Println(err.Error())
		}
		return
	}

	fmt.Println(result)
}
Output:

type ConditionBuilder

type ConditionBuilder struct {
	// contains filtered or unexported fields
}

ConditionBuilder represents Condition Expressions and Filter Expressions in DynamoDB. ConditionBuilders are one of the building blocks of the Builder struct. Since Filter Expressions support all the same functions and formats as Condition Expressions, ConditionBuilders represents both types of Expressions. More Information at: http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.ConditionExpressions.html More Information on Filter Expressions: http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Query.html#Query.FilterExpression

func And

func And(left, right ConditionBuilder, other ...ConditionBuilder) ConditionBuilder

And returns a ConditionBuilder representing the logical AND clause of the argument ConditionBuilders. 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. Note that And() can take a variadic number of ConditionBuilders as arguments.

Example:

// condition represents the condition where the item attribute "Name" is
// equal to value "Generic Name" AND the item attribute "Age" is less
// than value 40
condition := expression.And(expression.Name("Name").Equal(expression.Value("Generic Name")), expression.Name("Age").LessThan(expression.Value(40)))

// Used in another Condition Expression
anotherCondition := expression.Not(condition)
// Used to make an Builder
builder := expression.NewBuilder().WithCondition(condition)

Expression Equivalent:

expression.And(expression.Name("Name").Equal(expression.Value("Generic Name")), expression.Name("Age").LessThan(expression.Value(40)))
// Let #NAME, :name, and :forty be ExpressionAttributeName and
// ExpressionAttributeValues representing the item attribute "Name", the
// value "Generic Name", and the value 40
"(#NAME = :name) AND (Age < :forty)"

func AttributeExists

func AttributeExists(nameBuilder NameBuilder) 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.AttributeExists(expression.Name("Age"))

// Used in another Condition Expression
anotherCondition := expression.Not(condition)
// Used to make an Builder
builder := expression.NewBuilder().WithCondition(condition)

Expression Equivalent:

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

func AttributeNotExists

func AttributeNotExists(nameBuilder NameBuilder) 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.AttributeNotExists(expression.Name("Age"))

// Used in another Condition Expression
anotherCondition := expression.Not(condition)
// Used to make an Builder
builder := expression.NewBuilder().WithCondition(condition)

Expression Equivalent:

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

func AttributeType

func AttributeType(nameBuilder NameBuilder, 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.AttributeType(expression.Name("Age"), expression.Number)

// Used in another Condition Expression
anotherCondition := expression.Not(condition)
// Used to make an Builder
builder := expression.NewBuilder().WithCondition(condition)

Expression Equivalent:

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

func BeginsWith

func BeginsWith(nameBuilder NameBuilder, 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.BeginsWith(expression.Name("CodeName"), "Ben")

// Used in another Condition Expression
anotherCondition := expression.Not(condition)
// Used to make an Builder
builder := expression.NewBuilder().WithCondition(condition)

Expression Equivalent:

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

func Between

func Between(op, 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.Between(expression.Name("Rating"), 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.Between(expression.Name("Rating"), 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"

func Contains

func Contains(nameBuilder NameBuilder, 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.Contains(expression.Name("InviteList"), 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.Contains(expression.Name("InviteList"), expression.Value("Ben"))
// Let :ben be an ExpressionAttributeValue representing the value "Ben"
"contains (InviteList, :ben)"

func Equal

func Equal(left, 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.Equal(expression.Name("foo"), 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.Equal(expression.Name("foo"), expression.Value(5))
// Let :five be an ExpressionAttributeValue representing the value 5
"foo = :five"

func GreaterThan

func GreaterThan(left, 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.GreaterThan(expression.Name("foo"), 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.GreaterThan(expression.Name("foo"), expression.Value(5))
// Let :five be an ExpressionAttributeValue representing the value 5
"foo > :five"

func GreaterThanEqual

func GreaterThanEqual(left, 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.GreaterThanEqual(expression.Name("foo"), 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.GreaterThanEqual(expression.Name("foo"), expression.Value(5))
// Let :five be an ExpressionAttributeValue representing the value 5
"foo >= :five"

func In

func In(left, 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.In(expression.Name("Color"), 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.In(expression.Name("Color"), 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)"

func LessThan

func LessThan(left, 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.LessThan(expression.Name("foo"), 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.LessThan(expression.Name("foo"), expression.Value(5))
// Let :five be an ExpressionAttributeValue representing the value 5
"foo < :five"

func LessThanEqual

func LessThanEqual(left, 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.LessThanEqual(expression.Name("foo"), 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.LessThanEqual(expression.Name("foo"), expression.Value(5))
// Let :five be an ExpressionAttributeValue representing the value 5
"foo <= :five"

func Not

func Not(conditionBuilder ConditionBuilder) ConditionBuilder

Not returns a ConditionBuilder representing the logical NOT clause of the argument ConditionBuilder. 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 item attribute "Name"
// does not begin with "test"
condition := expression.Not(expression.Name("Name").BeginsWith("test"))

// Used in another Condition Expression
anotherCondition := expression.Not(condition)
// Used to make an Builder
builder := expression.NewBuilder().WithCondition(condition)

Expression Equivalent:

expression.Not(expression.Name("Name").BeginsWith("test"))
// Let :prefix be an ExpressionAttributeValue representing the value
// "test"
"NOT (begins_with (:prefix))"

func NotEqual

func NotEqual(left, 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.NotEqual(expression.Name("foo"), 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.NotEqual(expression.Name("foo"), expression.Value(5))
// Let :five be an ExpressionAttributeValue representing the value 5
"foo <> :five"

func Or

func Or(left, right ConditionBuilder, other ...ConditionBuilder) ConditionBuilder

Or returns a ConditionBuilder representing the logical OR clause of the argument ConditionBuilders. 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. Note that Or() can take a variadic number of ConditionBuilders as arguments.

Example:

// condition represents the condition where the item attribute "Price" is
// less than the value 100 OR the item attribute "Rating" is greater than
// the value 8
condition := expression.Or(expression.Name("Price").Equal(expression.Value(100)), expression.Name("Rating").LessThan(expression.Value(8)))

// Used in another Condition Expression
anotherCondition := expression.Not(condition)
// Used to make an Builder
builder := expression.NewBuilder().WithCondition(condition)

Expression Equivalent:

expression.Or(expression.Name("Price").Equal(expression.Value(100)), expression.Name("Rating").LessThan(expression.Value(8)))
// Let :price and :rating be ExpressionAttributeValues representing the
// the value 100 and value 8 respectively
"(Price < :price) OR (Rating > :rating)"

func (ConditionBuilder) And

And returns a ConditionBuilder representing the logical AND clause of the argument ConditionBuilders. 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. Note that And() can take a variadic number of ConditionBuilders as arguments.

Example:

// condition represents the condition where the item attribute "Name" is
// equal to value "Generic Name" AND the item attribute "Age" is less
// than value 40
condition := expression.Name("Name").Equal(expression.Value("Generic Name")).And(expression.Name("Age").LessThan(expression.Value(40)))

// Used in another Condition Expression
anotherCondition := expression.Not(condition)
// Used to make an Builder
builder := expression.NewBuilder().WithCondition(condition)

Expression Equivalent:

expression.Name("Name").Equal(expression.Value("Generic Name")).And(expression.Name("Age").LessThan(expression.Value(40)))
// Let #NAME, :name, and :forty be ExpressionAttributeName and
// ExpressionAttributeValues representing the item attribute "Name", the
// value "Generic Name", and the value 40
"(#NAME = :name) AND (Age < :forty)"

func (ConditionBuilder) Not

Not returns a ConditionBuilder representing the logical NOT clause of the argument ConditionBuilder. 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 item attribute "Name"
// does not begin with "test"
condition := expression.Name("Name").BeginsWith("test").Not()

// Used in another Condition Expression
anotherCondition := expression.Not(condition)
// Used to make an Builder
builder := expression.NewBuilder().WithCondition(condition)

Expression Equivalent:

expression.Name("Name").BeginsWith("test").Not()
// Let :prefix be an ExpressionAttributeValue representing the value
// "test"
"NOT (begins_with (:prefix))"

func (ConditionBuilder) Or

Or returns a ConditionBuilder representing the logical OR clause of the argument ConditionBuilders. 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. Note that Or() can take a variadic number of ConditionBuilders as arguments.

Example:

// condition represents the condition where the item attribute "Price" is
// less than the value 100 OR the item attribute "Rating" is greater than
// the value 8
condition := expression.Name("Price").Equal(expression.Value(100)).Or(expression.Name("Rating").LessThan(expression.Value(8)))

// Used in another Condition Expression
anotherCondition := expression.Not(condition)
// Used to make an Builder
builder := expression.NewBuilder().WithCondition(condition)

Expression Equivalent:

expression.Name("Price").Equal(expression.Value(100)).Or(expression.Name("Rating").LessThan(expression.Value(8)))
// Let :price and :rating be ExpressionAttributeValues representing the
// the value 100 and value 8 respectively
"(Price < :price) OR (Rating > :rating)"

type DynamoDBAttributeType

type DynamoDBAttributeType string

DynamoDBAttributeType specifies the type of an DynamoDB item attribute. This enum is used in the AttributeType() function in order to be explicit about the DynamoDB type that is being checked and ensure compile time checks. More Informatin at http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.OperatorsAndFunctions.html#Expressions.OperatorsAndFunctions.Functions

type Expression

type Expression struct {
	// contains filtered or unexported fields
}

Expression represents a collection of DynamoDB Expressions. The getter methods of the Expression struct retrieves the formatted DynamoDB Expressions, ExpressionAttributeNames, and ExpressionAttributeValues.

Example:

// keyCond represents the Key Condition Expression
keyCond := expression.Key("someKey").Equal(expression.Value("someValue"))
// proj represents the Projection Expression
proj := expression.NamesList(expression.Name("aName"), expression.Name("anotherName"), expression.Name("oneOtherName"))

// Add keyCond and proj to builder as a Key Condition and Projection
// respectively
builder := expression.NewBuilder().WithKeyCondition(keyCond).WithProjection(proj)
expression := builder.Build()

queryInput := dynamodb.QueryInput{
  KeyConditionExpression:    expression.KeyCondition(),
  ProjectionExpression:      expression.Projection(),
  ExpressionAttributeNames:  expression.Names(),
  ExpressionAttributeValues: expression.Values(),
  TableName: aws.String("SomeTable"),
}

func (Expression) Condition

func (e Expression) Condition() *string

Condition returns the *string corresponding to the Condition Expression of the argument Expression. This method is used to satisfy the members of DynamoDB input structs. If the Expression does not have a condition expression this method returns nil.

Example:

// let expression be an instance of Expression{}

deleteInput := dynamodb.DeleteItemInput{
  ConditionExpression:       expression.Condition(),
  ExpressionAttributeNames:  expression.Names(),
  ExpressionAttributeValues: expression.Values(),
  Key: map[string]*dynamodb.AttributeValue{
    "PartitionKey": &dynamodb.AttributeValue{
      S: aws.String("SomeKey"),
    },
  },
  TableName: aws.String("SomeTable"),
}

func (Expression) Filter

func (e Expression) Filter() *string

Filter returns the *string corresponding to the Filter Expression of the argument Expression. This method is used to satisfy the members of DynamoDB input structs. If the Expression does not have a filter expression this method returns nil.

Example:

// let expression be an instance of Expression{}

queryInput := dynamodb.QueryInput{
  KeyConditionExpression:    expression.KeyCondition(),
  FilterExpression:          expression.Filter(),
  ExpressionAttributeNames:  expression.Names(),
  ExpressionAttributeValues: expression.Values(),
  TableName: aws.String("SomeTable"),
}

func (Expression) KeyCondition

func (e Expression) KeyCondition() *string

KeyCondition returns the *string corresponding to the Key Condition Expression of the argument Expression. This method is used to satisfy the members of DynamoDB input structs. If the argument Expression does not have a KeyConditionExpression, KeyCondition() returns nil.

Example:

// let expression be an instance of Expression{}

queryInput := dynamodb.QueryInput{
  KeyConditionExpression:    expression.KeyCondition(),
  ProjectionExpression:      expression.Projection(),
  ExpressionAttributeNames:  expression.Names(),
  ExpressionAttributeValues: expression.Values(),
  TableName: aws.String("SomeTable"),
}

func (Expression) Names

func (e Expression) Names() map[string]*string

Names returns the map[string]*string corresponding to the ExpressionAttributeNames of the argument Expression. This method is used to satisfy the members of DynamoDB input structs. If Expression does not use ExpressionAttributeNames, this method returns nil. The ExpressionAttributeNames and ExpressionAttributeValues member of the input struct must always be assigned when using the Expression struct since all item attribute names and values are aliased. That means that if the ExpressionAttributeNames and ExpressionAttributeValues member is not assigned with the corresponding Names() and Values() methods, the DynamoDB operation will run into a logic error.

Example:

// let expression be an instance of Expression{}

queryInput := dynamodb.QueryInput{
  KeyConditionExpression:    expression.KeyCondition(),
  ProjectionExpression:      expression.Projection(),
  ExpressionAttributeNames:  expression.Names(),
  ExpressionAttributeValues: expression.Values(),
  TableName: aws.String("SomeTable"),
}

func (Expression) Projection

func (e Expression) Projection() *string

Projection returns the *string corresponding to the Projection Expression of the argument Expression. This method is used to satisfy the members of DynamoDB input structs. If the Expression does not have a projection expression this method returns nil.

Example:

// let expression be an instance of Expression{}

queryInput := dynamodb.QueryInput{
  KeyConditionExpression:    expression.KeyCondition(),
  ProjectionExpression:      expression.Projection(),
  ExpressionAttributeNames:  expression.Names(),
  ExpressionAttributeValues: expression.Values(),
  TableName: aws.String("SomeTable"),
}

func (Expression) Update

func (e Expression) Update() *string

Update returns the *string corresponding to the Update Expression of the argument Expression. This method is used to satisfy the members of DynamoDB input structs. If the argument Expression does not have a UpdateExpression, Update() returns nil.

Example:

// let expression be an instance of Expression{}

updateInput := dynamodb.UpdateInput{
  Key: map[string]*dynamodb.AttributeValue{
    "PartitionKey": {
      S: aws.String("someKey"),
    },
  },
  UpdateExpression:          expression.Update(),
  ExpressionAttributeNames:  expression.Names(),
  ExpressionAttributeValues: expression.Values(),
  TableName: aws.String("SomeTable"),
}

func (Expression) Values

func (e Expression) Values() map[string]*dynamodb.AttributeValue

Values returns the map[string]*dynamodb.AttributeValue corresponding to the ExpressionAttributeValues of the argument Expression. This method is used to satisfy the members of DynamoDB input structs. If Expression does not use ExpressionAttributeValues, this method returns nil. The ExpressionAttributeNames and ExpressionAttributeValues member of the input struct must always be assigned when using the Expression struct since all item attribute names and values are aliased. That means that if the ExpressionAttributeNames and ExpressionAttributeValues member is not assigned with the corresponding Names() and Values() methods, the DynamoDB operation will run into a logic error.

Example:

// let expression be an instance of Expression{}

queryInput := dynamodb.QueryInput{
  KeyConditionExpression:    expression.KeyCondition(),
  ProjectionExpression:      expression.Projection(),
  ExpressionAttributeNames:  expression.Names(),
  ExpressionAttributeValues: expression.Values(),
  TableName: aws.String("SomeTable"),
}

type InvalidParameterError

type InvalidParameterError struct {
	// contains filtered or unexported fields
}

InvalidParameterError is returned if invalid parameters are encountered. This error specifically refers to situations where parameters are non-empty but have an invalid syntax/format. The error message includes the function that returned the error originally and the parameter type that was deemed invalid.

Example:

// err is of type InvalidParameterError
_, err := expression.Name("foo..bar").BuildOperand()

func (InvalidParameterError) Error

func (ipe InvalidParameterError) Error() string

type KeyBuilder

type KeyBuilder struct {
	// contains filtered or unexported fields
}

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")

func Key

func Key(key string) KeyBuilder

Key creates a KeyBuilder. The argument should represent the desired partition key or sort key value. KeyBuilders should only be used to specify relationships for Key Condition Expressions. When referring to the partition key or sort key in any other Expression, use Name().

Example:

// Use Key() to create a key condition expression
keyCondition := expression.Key("foo").Equal(expression.Value("bar"))

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

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

func (KeyBuilder) 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 http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ReservedWords.html

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

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

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

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

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

type KeyConditionBuilder

type KeyConditionBuilder struct {
	// contains filtered or unexported fields
}

KeyConditionBuilder represents Key Condition Expressions in DynamoDB. KeyConditionBuilders are the building blocks of Expressions. More Information at: http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Query.html#Query.KeyConditionExpressions

func KeyAnd

func KeyAnd(left, right KeyConditionBuilder) KeyConditionBuilder

KeyAnd returns a KeyConditionBuilder representing the logical AND clause of the two argument KeyConditionBuilders. The resulting KeyConditionBuilder can be used as an argument to the WithKeyCondition() method for the Builder struct.

Example:

// keyCondition represents the key condition where the partition key
// "TeamName" is equal to value "Wildcats" and sort key "Number" is equal
// to value 1
keyCondition := expression.KeyAnd(expression.Key("TeamName").Equal(expression.Value("Wildcats")), expression.Key("Number").Equal(expression.Value(1)))

// Used to make an Builder
builder := expression.NewBuilder().WithKeyCondition(keyCondition)

Expression Equivalent:

expression.KeyAnd(expression.Key("TeamName").Equal(expression.Value("Wildcats")), expression.Key("Number").Equal(expression.Value(1)))
// Let #NUMBER, :teamName, and :one be ExpressionAttributeName and
// ExpressionAttributeValues representing the item attribute "Number",
// the value "Wildcats", and the value 1
"(TeamName = :teamName) AND (#NUMBER = :one)"

func KeyBeginsWith

func KeyBeginsWith(keyBuilder KeyBuilder, prefix string) KeyConditionBuilder

KeyBeginsWith 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.KeyBeginsWith(expression.Key("foo"), "bar")

// Used in another Key Condition Expression
anotherKeyCondition := expression.Key("partitionKey").Equal(expression.Value("aValue")).And(keyCondition)

Expression Equivalent:

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

func KeyBetween

func KeyBetween(keyBuilder KeyBuilder, lower, upper ValueBuilder) KeyConditionBuilder

KeyBetween 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.KeyBetween(expression.Key("foo"), 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.KeyBetween(expression.Key("foo"), expression.Value(5), expression.Value(10))
// Let :five and :ten be ExpressionAttributeValues representing the
// values 5 and 10 respectively
"foo BETWEEN :five AND :ten"

func KeyEqual

func KeyEqual(keyBuilder KeyBuilder, valueBuilder ValueBuilder) KeyConditionBuilder

KeyEqual 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.KeyEqual(expression.Key("foo"), 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.KeyEqual(expression.Key("foo"), expression.Value(5))
// Let :five be an ExpressionAttributeValue representing the value 5
"foo = :five"

func KeyGreaterThan

func KeyGreaterThan(keyBuilder KeyBuilder, valueBuilder ValueBuilder) KeyConditionBuilder

KeyGreaterThan 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:

// keyCondition represents the greater than clause of the key "foo" and
// the value 5
keyCondition := expression.KeyGreaterThan(expression.Key("foo"), expression.Value(5))

// Used in another Key Condition Expression
anotherKeyCondition := expression.Key("partitionKey").Equal(expression.Value("aValue")).And(keyCondition)

Expression Equivalent:

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

func KeyGreaterThanEqual

func KeyGreaterThanEqual(keyBuilder KeyBuilder, valueBuilder ValueBuilder) KeyConditionBuilder

KeyGreaterThanEqual 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.KeyGreaterThanEqual(expression.Key("foo"), expression.Value(5))

// Used in another Key Condition Expression
anotherKeyCondition := expression.Key("partitionKey").Equal(expression.Value("aValue")).And(keyCondition)

Expression Equivalent:

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

func KeyLessThan

func KeyLessThan(keyBuilder KeyBuilder, valueBuilder ValueBuilder) KeyConditionBuilder

KeyLessThan 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.KeyLessThan(expression.Key("foo"), expression.Value(5))

// Used in another Key Condition Expression
anotherKeyCondition := expression.Key("partitionKey").Equal(expression.Value("aValue")).And(keyCondition)

Expression Equivalent:

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

func KeyLessThanEqual

func KeyLessThanEqual(keyBuilder KeyBuilder, valueBuilder ValueBuilder) KeyConditionBuilder

KeyLessThanEqual 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.KeyLessThanEqual(expression.Key("foo"), expression.Value(5))

// Used in another Key Condition Expression
anotherKeyCondition := expression.Key("partitionKey").Equal(expression.Value("aValue")).And(keyCondition)

Expression Equivalent:

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

func (KeyConditionBuilder) And

And returns a KeyConditionBuilder representing the logical AND clause of the two argument KeyConditionBuilders. The resulting KeyConditionBuilder can be used as an argument to the WithKeyCondition() method for the Builder struct.

Example:

// keyCondition represents the key condition where the partition key
// "TeamName" is equal to value "Wildcats" and sort key "Number" is equal
// to value 1
keyCondition := expression.Key("TeamName").Equal(expression.Value("Wildcats")).And(expression.Key("Number").Equal(expression.Value(1)))

// Used to make an Builder
builder := expression.NewBuilder().WithKeyCondition(keyCondition)

Expression Equivalent:

expression.Key("TeamName").Equal(expression.Value("Wildcats")).And(expression.Key("Number").Equal(expression.Value(1)))
// Let #NUMBER, :teamName, and :one be ExpressionAttributeName and
// ExpressionAttributeValues representing the item attribute "Number",
// the value "Wildcats", and the value 1
"(TeamName = :teamName) AND (#NUMBER = :one)"

type NameBuilder

type NameBuilder struct {
	// contains filtered or unexported fields
}

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")

func Name

func Name(name string) NameBuilder

Name creates a NameBuilder. The argument should represent the desired item attribute. It is possible to reference nested item attributes by using square brackets for lists and dots for maps. For documentation on specifying item attributes, see: http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.Attributes.html

Example:

// Specify a top-level attribute
name := expression.Name("TopLevel")
// Specify a nested attribute
nested := expression.Name("Record[6].SongList")
// Use Name() to create a condition expression
condition := expression.Name("foo").Equal(expression.Name("bar"))

func (NameBuilder) 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))"

func (NameBuilder) 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))"

func (NameBuilder) 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)"

func (NameBuilder) 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)"

func (NameBuilder) 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"

func (NameBuilder) 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 http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ReservedWords.html

func (NameBuilder) 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)"

func (NameBuilder) Equal

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"

func (NameBuilder) 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"

func (NameBuilder) 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"

func (NameBuilder) 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: http://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)"

func (NameBuilder) In

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)"

func (NameBuilder) 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"

func (NameBuilder) 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"

func (NameBuilder) 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: http://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)"

func (NameBuilder) 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: http://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"

func (NameBuilder) 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"

func (NameBuilder) 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"

func (NameBuilder) 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: http://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"

func (NameBuilder) 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: http://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)"

type Operand

type Operand struct {
	// contains filtered or unexported fields
}

Operand represents an item attribute name or value in DynamoDB. The relationship between Operands specified by various builders such as ConditionBuilders and UpdateBuilders for example is processed internally to write Condition Expressions and Update Expressions respectively.

type OperandBuilder

type OperandBuilder interface {
	BuildOperand() (Operand, error)
}

OperandBuilder represents the idea of Operand 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. OperandBuilder and BuildOperand() are exported to allow package functions to take an interface as an argument.

type ProjectionBuilder

type ProjectionBuilder struct {
	// contains filtered or unexported fields
}

ProjectionBuilder represents Projection Expressions in DynamoDB. ProjectionBuilders are the building blocks of Builders. More Information at: http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.ProjectionExpressions.html

func AddNames

func AddNames(projectionBuilder ProjectionBuilder, namesList ...NameBuilder) ProjectionBuilder

AddNames returns a ProjectionBuilder representing the list of item attribute names equivalent to appending all of the argument item attribute names to the argument ProjectionBuilder. 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", "baz", "qux"}
oldProj := expression.NamesList(expression.Name("foo"), expression.Name("bar"))
projection := expression.AddNames(oldProj, expression.Name("baz"), expression.Name("qux"))

// Used in another Projection Expression
anotherProjection := expression.AddNames(projection, expression.Name("quux"))
// Used to make an Builder
builder := expression.NewBuilder().WithProjection(newProjection)

Expression Equivalent:

expression.AddNames(expression.NamesList(expression.Name("foo"), expression.Name("bar")), expression.Name("baz"), expression.Name("qux"))
"foo, bar, baz, qux"

func NamesList

func NamesList(nameBuilder NameBuilder, 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.NamesList(expression.Name("foo"), 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.NamesList(expression.Name("foo"), expression.Name("bar"))
"foo, bar"

func (ProjectionBuilder) AddNames

func (pb ProjectionBuilder) AddNames(namesList ...NameBuilder) ProjectionBuilder

AddNames returns a ProjectionBuilder representing the list of item attribute names equivalent to appending all of the argument item attribute names to the argument ProjectionBuilder. 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", "baz", "qux"}
oldProj := expression.NamesList(expression.Name("foo"), expression.Name("bar"))
projection := oldProj.AddNames(expression.Name("baz"), expression.Name("qux"))

// Used in another Projection Expression
anotherProjection := expression.AddNames(projection, expression.Name("quux"))
// Used to make an Builder
builder := expression.NewBuilder().WithProjection(newProjection)

Expression Equivalent:

expression.NamesList(expression.Name("foo"), expression.Name("bar")).AddNames(expression.Name("baz"), expression.Name("qux"))
"foo, bar, baz, qux"

type SetValueBuilder

type SetValueBuilder struct {
	// contains filtered or unexported fields
}

SetValueBuilder represents the outcome of operator functions supported by the DynamoDB Set operation. The operator functions are the following:

Plus()  // Represents the "+" operator
Minus() // Represents the "-" operator
ListAppend()
IfNotExists()

For documentation on the above functions, see: http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.UpdateExpressions.html#Expressions.UpdateExpressions.SET Since SetValueBuilder represents an operand, it implements the OperandBuilder interface. SetValueBuilder structs are used as arguments to the Set() function. SetValueBuilders should only initialize a SetValueBuilder using the functions listed above.

func IfNotExists

func IfNotExists(name NameBuilder, setValue 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: http://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.IfNotExists(expression.Name("someName"), expression.Value(5)))

Expression Equivalent:

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

func ListAppend

func ListAppend(leftOperand, 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: http://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.ListAppend(expression.Name("nameOfList"), expression.Value([]string{"some", "list"})))

Expression Equivalent:

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

func Minus

func Minus(leftOperand, 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: http://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 5 - 10
update, err := expression.Set(expression.Name("someName"), expression.Minus(expression.Value(5), expression.Value(10)))

Expression Equivalent:

expression.Minus(expression.Value(5), expression.Value(10))
// let :five and :ten be ExpressionAttributeValues for the values 5 and
// 10 respectively.
":five - :ten"

func Plus

func Plus(leftOperand, 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: http://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 5 + 10
update, err := expression.Set(expression.Name("someName"), expression.Plus(expression.Value(5), expression.Value(10)))

Expression Equivalent:

expression.Plus(expression.Value(5), expression.Value(10))
// let :five and :ten be ExpressionAttributeValues for the values 5 and
// 10 respectively.
":five + :ten"

func (SetValueBuilder) BuildOperand

func (svb SetValueBuilder) 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 http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ReservedWords.html

type SizeBuilder

type SizeBuilder struct {
	// contains filtered or unexported fields
}

SizeBuilder represents the output of the function size ("someName"), which evaluates to the size of the item attribute defined by "someName". Since SizeBuilder represents an operand, SizeBuilder implements the OperandBuilder interface. Methods and functions in the package take SizeBuilder as an argument and establishes relationships between operands. SizeBuilder should only be initialized using the function Size().

Example:

// Create a SizeBuilder representing the size of the item attribute
// "aName"
sizeBuilder := expression.Name("aName").Size()

func Size

func Size(nameBuilder NameBuilder) 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: http://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.Size(expression.Name("foo")).Equal(expression.Value(10))

Expression Equivalent:

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

func (SizeBuilder) Between

func (sb SizeBuilder) 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 size of the item
// attribute "InviteList" is between values 5 and 10
condition := expression.Size(expression.Name("InviteList")).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.Size(expression.Name("InviteList")).Between(expression.Value(5), expression.Value(10))
// Let :five and :ten be ExpressionAttributeValues representing the value
// 5 and the value 10
"size (InviteList) BETWEEN :five AND :ten"

func (SizeBuilder) BuildOperand

func (sb SizeBuilder) 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 http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ReservedWords.html

func (SizeBuilder) Equal

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 size of the item
// attribute "foo" and the value 5
condition := expression.Size(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.Size(expression.Name("foo")).Equal(expression.Value(5))
// Let :five be an ExpressionAttributeValue representing the value 5
"size (foo) = :five"

func (SizeBuilder) GreaterThan

func (sb SizeBuilder) 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 size of the item
// attribute "foo" and the value 5
condition := expression.Size(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.Size(expression.Name("foo")).GreaterThan(expression.Value(5))
// Let :five be an ExpressionAttributeValue representing the value 5
"size (foo) > :five"

func (SizeBuilder) GreaterThanEqual

func (sb SizeBuilder) 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 size of
// the item attribute "foo" and the value 5
condition := expression.Size(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.Size(expression.Name("foo")).GreaterThanEqual(expression.Value(5))
// Let :five be an ExpressionAttributeValue representing the value 5
"size (foo) >= :five"

func (SizeBuilder) In

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 size of the item
// attribute "Donuts" is checked against the list of numbers 12, 24, and
// 36.
condition := expression.Size(expression.Name("Donuts")).In(expression.Value(12), expression.Value(24), expression.Value(36))

// Used in another Condition Expression
anotherCondition := expression.Not(condition)
// Used to make an Builder
builder := expression.NewBuilder().WithCondition(condition)

Expression Equivalent:

expression.Size(expression.Name("Donuts")).In(expression.Value(12), expression.Value(24), expression.Value(36))
// Let :dozen, :twoDozen, :threeDozen be ExpressionAttributeValues
// representing the values 12, 24, and 36 respectively
"size (Donuts) IN (12, 24, 36)"

func (SizeBuilder) LessThan

func (sb SizeBuilder) 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 size of the item
// attribute "foo" and the value 5
condition := expression.Size(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.Size(expression.Name("foo")).LessThan(expression.Value(5))
// Let :five be an ExpressionAttributeValue representing the value 5
"size (foo) < :five"

func (SizeBuilder) LessThanEqual

func (sb SizeBuilder) 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 size of the
// item attribute "foo" and the value 5
condition := expression.Size(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.Size(expression.Name("foo")).LessThanEqual(expression.Value(5))
// Let :five be an ExpressionAttributeValue representing the value 5
"size (foo) <= :five"

func (SizeBuilder) NotEqual

func (sb SizeBuilder) 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 size of the item
// attribute "foo" and the value 5
condition := expression.Size(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.Size(expression.Name("foo")).NotEqual(expression.Value(5))
// Let :five be an ExpressionAttributeValue representing the value 5
"size (foo) <> :five"

type UnsetParameterError

type UnsetParameterError struct {
	// contains filtered or unexported fields
}

UnsetParameterError is returned if parameters are empty and uninitialized. This error is returned if opaque structs (ConditionBuilder, NameBuilder, Builder, etc) are initialized outside of functions in the package, since all structs in the package are designed to be initialized with functions.

Example:

// err is of type UnsetParameterError
_, err := expression.Builder{}.Build()
_, err := expression.NewBuilder().
            WithCondition(expression.ConditionBuilder{}).
            Build()

func (UnsetParameterError) Error

func (upe UnsetParameterError) Error() string

type UpdateBuilder

type UpdateBuilder struct {
	// contains filtered or unexported fields
}

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: http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.UpdateExpressions.html

func Add

func Add(name NameBuilder, value ValueBuilder) UpdateBuilder

Add returns an UpdateBuilder representing the Add operation for DynamoDB Update Expressions. 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:

// update represents the add operation to add the value 5 to the item
// attribute "aPath"
update := expression.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:

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

func Delete

func Delete(name NameBuilder, value ValueBuilder) UpdateBuilder

Delete returns an UpdateBuilder representing one Delete operation for DynamoDB Update Expressions. 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:

// update represents the delete operation to delete the string value
// "subsetToDelete" from the item attribute "pathToList"
update := expression.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:

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

func Remove

func Remove(name NameBuilder) UpdateBuilder

Remove returns an UpdateBuilder representing the Remove operation for DynamoDB Update Expressions. 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:

// update represents the remove operation to remove the item attribute
// "itemToRemove"
update := expression.Remove(expression.Name("itemToRemove"))

// Adding more update methods
anotherUpdate := update.Remove(expression.Name("someName"))
// Creating a Builder
builder := Update(update)

Expression Equivalent:

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

func Set

func Set(name NameBuilder, operandBuilder OperandBuilder) UpdateBuilder

Set returns an UpdateBuilder representing the Set operation for DynamoDB Update Expressions. 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:

// update represents the set operation to set the item attribute
// "itemToSet" to the value "setValue" if the item attribute does not
// exist yet. (conditional write)
update := expression.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:

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

func (UpdateBuilder) Add

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"

func (UpdateBuilder) 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"

func (UpdateBuilder) 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"

func (UpdateBuilder) 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"

type ValueBuilder

type ValueBuilder struct {
	// contains filtered or unexported fields
}

ValueBuilder represents an item attribute value operand and implements the OperandBuilder interface. Methods and functions in the package take ValueBuilder as an argument and establishes relationships between operands. ValueBuilder should only be initialized using the function Value().

Example:

// Create a ValueBuilder representing the string "aValue"
valueBuilder := expression.Value("aValue")

func Value

func Value(value interface{}) ValueBuilder

Value creates a ValueBuilder. The argument should represent the desired item attribute. The value is marshalled using the dynamodbattribute package by the Build() method for type Builder.

Example:

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

func (ValueBuilder) Between

func (vb ValueBuilder) 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 6 is between values
// 5 and 10
condition := expression.Value(6).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.Value(6).Between(expression.Value(5), expression.Value(10))
// Let :six, :five and :ten be ExpressionAttributeValues representing the
// values 6, 5, and 10 respectively
":six BETWEEN :five AND :ten"

func (ValueBuilder) BuildOperand

func (vb ValueBuilder) 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 http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ReservedWords.html

func (ValueBuilder) Equal

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.Value(5).Equal(expression.Name("foo"))

// Used in another Condition Expression
anotherCondition := expression.Not(condition)
// Used to make an Builder
builder := expression.NewBuilder().WithCondition(condition)

Expression Equivalent:

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

func (ValueBuilder) GreaterThan

func (vb ValueBuilder) 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.Value(5).GreaterThan(expression.Name("foo"))

// Used in another Condition Expression
anotherCondition := expression.Not(condition)
// Used to make an Builder
builder := expression.NewBuilder().WithCondition(condition)

Expression Equivalent:

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

func (ValueBuilder) GreaterThanEqual

func (vb ValueBuilder) 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.Value(5).GreaterThanEqual(expression.Name("foo"))

// Used in another Condition Expression
anotherCondition := expression.Not(condition)
// Used to make an Builder
builder := expression.NewBuilder().WithCondition(condition)

Expression Equivalent:

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

func (ValueBuilder) In

In returns a ConditionBuilder representing the result of the IN function TODO change this one 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 "yellow" is checked
// against the list of colors "red", "green", and "blue".
condition := expression.Value("yellow").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.Value("yellow").In(expression.Value("red"), expression.Value("green"), expression.Value("blue"))
// Let :yellow, :red, :green, :blue be ExpressionAttributeValues
// representing the values "yellow", "red", "green", and "blue"
// respectively
":yellow IN (:red, :green, :blue)"

func (ValueBuilder) LessThan

func (vb ValueBuilder) 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.Value(5).LessThan(expression.Name("foo"))

// Used in another Condition Expression
anotherCondition := expression.Not(condition)
// Used to make an Builder
builder := expression.NewBuilder().WithCondition(condition)

Expression Equivalent:

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

func (ValueBuilder) LessThanEqual

func (vb ValueBuilder) 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.Value(5).LessThanEqual(expression.Name("foo"))

// Used in another Condition Expression
anotherCondition := expression.Not(condition)
// Used to make an Builder
builder := expression.NewBuilder().WithCondition(condition)

Expression Equivalent:

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

func (ValueBuilder) ListAppend

func (vb ValueBuilder) 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: http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.UpdateExpressions.html#Expressions.UpdateExpressions.SET.UpdatingListElements

Example:

// Use ListAppend() to set item attribute "someName" to a string list
// equal to {"a", "list", "some", "list"}
update, err := expression.Set(expression.Name("someName"), expression.Value([]string{"a", "list"}).ListAppend(expression.Value([]string{"some", "list"})))

Expression Equivalent:

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

func (ValueBuilder) Minus

func (vb ValueBuilder) 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: http://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 5 - 10
update, err := expression.Set(expression.Name("someName"), expression.Value(5).Minus(expression.Value(10)))

Expression Equivalent:

expression.Value(5).Minus(expression.Value(10))
// let :five and :ten be ExpressionAttributeValues for the values 5 and
// 10 respectively.
":five - :ten"

func (ValueBuilder) NotEqual

func (vb ValueBuilder) 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.Value(5).NotEqual(expression.Name("foo"))

// Used in another Condition Expression
anotherCondition := expression.Not(condition)
// Used to make an Builder
builder := expression.NewBuilder().WithCondition(condition)

Expression Equivalent:

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

func (ValueBuilder) Plus

func (vb ValueBuilder) 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: http://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 5 + 10
update, err := expression.Set(expression.Name("someName"), expression.Value(5).Plus(expression.Value(10)))

Expression Equivalent:

expression.Value(5).Plus(expression.Value(10))
// let :five and :ten be ExpressionAttributeValues representing the value
// 5 and 10 respectively
":five + :ten"

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL