You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
(It is hinted at above, but for the sake of clarity I'll note that I've written machinery to normalize LocalDate to a Long for comfortable reading and writing. It's not relevant to the issue at hand, but I want the behavior described to make sense)
So, when I go to write entries, I can write an Entry("someId", Rich("low-cardinality", LocalDate.now()), LocalDate.now()) and get a row in Dynamo like
partitionKey
sortKey
date
someId
low-cardinality#12345
12345
This is all lovely, but I'd like to be able to use a SortKeyQuery to target my queries more specifically. In particular, I'd like to be able to say BeginsWith("low-cardinality"), but I can't since the S has to be Rich. E.g.,
The first only allows me to construct SortKeyQuery[Rich], while the second lets me do whatever with the string rep at the cost of type safety. I'd really love to be able to represent a more principled query, but I don't know if the tools exist in the library to do so.
This feels like something that could be solvable with optics, but I'm not quite sure how to go about it. It seems like I ought to be able to construct a Prism[Rich, String] (the real code uses newtypes pervasively, so it wouldn't actually be String) and then use that to construct a SortKeyQuery specialized to one or more parts of the sort key.
I'm on vacation for the next couple of weeks, so I may see if I can grok enough of the code that's already here to prove out that idea, but I figured I'd throw the idea out in case it gave you an AHA! moment.
The text was updated successfully, but these errors were encountered:
AWS Docs: https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/bp-sort-keys.html
Context:
Suppose the following type represents an entry in a Dynamo table:
We define a composite sort key by:
(It is hinted at above, but for the sake of clarity I'll note that I've written machinery to normalize
LocalDate
to aLong
for comfortable reading and writing. It's not relevant to the issue at hand, but I want the behavior described to make sense)So, when I go to write entries, I can write an
Entry("someId", Rich("low-cardinality", LocalDate.now()), LocalDate.now())
and get a row in Dynamo likepartitionKey
sortKey
date
someId
low-cardinality#12345
12345
This is all lovely, but I'd like to be able to use a
SortKeyQuery
to target my queries more specifically. In particular, I'd like to be able to sayBeginsWith("low-cardinality")
, but I can't since theS
has to beRich
. E.g.,The first only allows me to construct
SortKeyQuery[Rich]
, while the second lets me do whatever with the string rep at the cost of type safety. I'd really love to be able to represent a more principled query, but I don't know if the tools exist in the library to do so.This feels like something that could be solvable with optics, but I'm not quite sure how to go about it. It seems like I ought to be able to construct a
Prism[Rich, String]
(the real code uses newtypes pervasively, so it wouldn't actually beString
) and then use that to construct aSortKeyQuery
specialized to one or more parts of the sort key.I'm on vacation for the next couple of weeks, so I may see if I can grok enough of the code that's already here to prove out that idea, but I figured I'd throw the idea out in case it gave you an AHA! moment.
The text was updated successfully, but these errors were encountered: