Skip to content

ExpressionLiteral

Compare
Choose a tag to compare
@guregu guregu released this 08 Mar 16:38
· 95 commits to master since this release

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

  • add ExpressionLiteral for passing in raw expressions and placeholders by @guregu in #192

Full Changelog: v1.13.0...v1.14.0