I am attempting to filter a DynamoDb scan by multiple conditions using the expression builder. According to this blog post, attempting to add another condition in the builder will overwrite the previous condition. There must be some way to add another condition, but I have not been able to find a way to do it.
This won't work
cond1 := expression.Name("foo").Equal(expression.Value(5))
cond2 := expression.Name("bar").Equal(expression.Value(6))
expr, err := expression.NewBuilder().
WithCondition(cond1).
WithCondition(cond2).
Build()
if err != nil {
fmt.Println(err)
}
This is a working example with a single filter
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"),
}
I have been able to accomplish this without using the expression buidler, but I would prefer to use the expression builder. How could I add another condition to that filter?