ExpressionLiteral
Summary
This release adds a new type, ExpressionLiteral
(#192). It represents a raw DynamoDB expression and placeholders, using the same data types as the official AWS package. You can pass this as a parameter to any method that takes an expression. Both $
and ?
will work as variables. dynamo will automatically merge your placeholders with its own, so you can use this in tandem with the rest of the library.
Some use cases include porting projects from the official SDK, and passing around search parameters in APIs.
Be careful, using this is akin to manipulating SQL queries with string concatenation. Make sure you know what you're doing if you use it. Only reach for this hammer when the regular APIs don't cut it.
Example
lit := dynamo.ExpressionLiteral{
Expression: "#meta.#foo = :bar",
AttributeNames: aws.StringMap(map[string]string{
"#meta": "Meta",
"#foo": "foo",
}),
AttributeValues: map[string]*dynamodb.AttributeValue{
":bar": {S: aws.String("bar")},
},
}
err := table.Get("UserID", 42).
Filter("?", lit). // $ also works.
All(&result)
What's Changed
Full Changelog: v1.13.0...v1.14.0