github.com/aavshr/aws-sdk-go@v1.41.3/service/dynamodb/expression/doc.go (about)

     1  /*
     2  Package expression provides types and functions to create Amazon DynamoDB
     3  Expression strings, ExpressionAttributeNames maps, and ExpressionAttributeValues
     4  maps.
     5  
     6  Using the Package
     7  
     8  The package represents the various DynamoDB Expressions as structs named
     9  accordingly. For example, ConditionBuilder represents a DynamoDB Condition
    10  Expression, an UpdateBuilder represents a DynamoDB Update Expression, and so on.
    11  The following example shows a sample ConditionExpression and how to build an
    12  equilvalent ConditionBuilder
    13  
    14    // Let :a be an ExpressionAttributeValue representing the string "No One You
    15    // Know"
    16    condExpr := "Artist = :a"
    17    condBuilder := expression.Name("Artist").Equal(expression.Value("No One You Know"))
    18  
    19  In order to retrieve the formatted DynamoDB Expression strings, call the getter
    20  methods on the Expression struct. To create the Expression struct, call the
    21  Build() method on the Builder struct. Because some input structs, such as
    22  QueryInput, can have multiple DynamoDB Expressions, multiple structs
    23  representing various DynamoDB Expressions can be added to the Builder struct.
    24  The following example shows a generic usage of the whole package.
    25  
    26    filt := expression.Name("Artist").Equal(expression.Value("No One You Know"))
    27    proj := expression.NamesList(expression.Name("SongTitle"), expression.Name("AlbumTitle"))
    28    expr, err := expression.NewBuilder().WithFilter(filt).WithProjection(proj).Build()
    29    if err != nil {
    30      fmt.Println(err)
    31    }
    32  
    33    input := &dynamodb.ScanInput{
    34      ExpressionAttributeNames:  expr.Names(),
    35      ExpressionAttributeValues: expr.Values(),
    36      FilterExpression:          expr.Filter(),
    37      ProjectionExpression:      expr.Projection(),
    38      TableName:                 aws.String("Music"),
    39    }
    40  
    41  The ExpressionAttributeNames and ExpressionAttributeValues member of the input
    42  struct must always be assigned when using the Expression struct because all item
    43  attribute names and values are aliased. That means that if the
    44  ExpressionAttributeNames and ExpressionAttributeValues member is not assigned
    45  with the corresponding Names() and Values() methods, the DynamoDB operation will
    46  run into a logic error.
    47  */
    48  package expression