Skip to content

Conversation

guregu
Copy link
Owner

@guregu guregu commented Mar 8, 2022

This adds a new type called ExpressionLiteral, which allows you to pass raw DynamoDB expressions to any method that takes an expression. dynamo will merge your placeholders with its own, rewriting your expression a little bit to avoid clobbering our automatically generated placeholders.
You can use either $ or ? as the variable when passing this as an argument to functions like FilterExpr.
Be careful with this, especially if you use it with Update or for conditional writes. Improper usage could open yourself up to injection attacks. I definitely do not recommend that. Think of this like using string concatenation to build SQL.

One of the major features of this library is abstracting placeholder management away from you. My hope is that most people won't have to use this, but it can be useful for certain things.
You can use this along with AWS's expression library. This is helpful for people who want to move from the official AWS SDK to ours, or vice-versa. Perhaps we will want to support this passing in objects from this package explicitly later on, but for now it's easy to convert between the two.
Another use case would be if you wanted to take DynamoDB expressions as user input for implementing search parameters. Why not take advantage of the JS library? 🤠

@guregu guregu merged commit 013b64b into master Mar 8, 2022
@guregu guregu deleted the raw-expr branch March 8, 2022 12:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant