[Beyonce]: Support inverted indexes #37
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds support for creating an "inverted index" -- which is a particular flavor of a GSI.
You can click the link above for more context, but the basic idea is it's often useful to flip your primary table's partition and sort keys in a GSI. Often this "unlocks" several new query patterns -- e.g. querying the "other side" of a relationship.
Previously, when defining a GSI we wouldn't allow you to use "key fields" on a model (i.e. a field that is synthesized when you call
FooModel.create({ ... })
). Now we allow you to specify your table's partition key or sort key.A nice future improvement that's out of scope for this PR would be to split model definitions into "data fields" and "key fields". This would allow for defining arbitrary fields on your model that would be automatically synthesized when you call
.create({ ... })
. You can think of "partitionKey" and "sortKey" as being special cases of that idea -- e.g.: