Robert Chandler
04/20/2022, 12:35 AMthdxr
04/20/2022, 12:35 AMthdxr
04/20/2022, 12:36 AMRobert Chandler
04/20/2022, 12:36 AMthdxr
04/20/2022, 12:36 AMthdxr
04/20/2022, 12:36 AMRobert Chandler
04/20/2022, 12:37 AMJono Allen
04/20/2022, 3:34 AMthdxr
04/20/2022, 3:35 AMJono Allen
04/20/2022, 3:37 AMthdxr
04/20/2022, 3:42 AMTyler Walch
04/20/2022, 3:59 AMTyler Walch
04/20/2022, 4:45 AMraw
, item
, and named
. The raw
option is the easiest to grep; it is the LastEvaluatedKey
as it was returned in the DocumentClient results. The item
and named
options are pretty much the same concept: ElectroDB will use its knowledge of key structures to disassemble the LastEvaluatedKey
into its constituent parts.
For example, if LastEvaluatedKey
looks like this:
{
pk: '$taskapp#country_united states of america#state_oregon',
sk: '$offices_1#city_portland#zip_34706#office_mobile branch'
}
ElectroDB knows how the key is formed un-parse the key into its individual parts:
{
"city": "portland",
"country": "united states of america",
"state": "oregon",
"zip": "34706",
"office": "mobile branch"
}
When I first started building ElectroDB I was designing a Transaction Warehouse for a Credit Union platform. Two challenges from that project when using DynamoDB was the following:
1. The key expressions applied to a query had no bearing on the LastEvaluatedKey
returned from DynamoDB. This had the unfortunate consequence of leaking keys to the frontend which was likely to include the accountIds and transactionIds of other members.
2. Some attributes of a key, for example a UserId
, should never come from the user themselves. Those types of values should come from a session or some other authorized source.
In both cases breaking out the individual attributes from a LastEvaluatedKey
was helpful in mitigating these issues. It allowed me to add additional logic around what was exposed to the user, and what was required to be supplied by the user to paginate.
I can go into detail about any of these concepts further if you have any questions. There are some caveats to the above worth discussing. I am interested in hearing more about your needs, and possibly extending ElectroDB to fit those as well đ
On the roadmap I have felt the addition of a fourth option (cursor
) that returns a single string would be very helpful for many users. Lastly, I also have a WIP branch that adds (non-breaking) AsyncIteration to the existing pagination API for a nicer DX.thdxr
04/20/2022, 4:48 AMJono Allen
04/26/2022, 9:00 AMpk
and sk
and then encrypting it. My main issue is if the key changes the pagination breaks.
When i say âproductionâ what i was meaning was something that can exist in url, that is safe and canât pose any risks but is also reliable/backwards compatible and safe to future changes. (ie key changing etc)
I really like the idea of adding a cursor
option as it solves the issue of not having a single reference which is supported by the data layer and the application code doesnât need to add any abstractions to provide a reference to the frontend.Tyler Walch
04/28/2022, 12:14 AMJono Allen
04/28/2022, 12:34 AM(ie key changing etc)
I was referring to the secret changing on the encrypted key would break the pagination. Like when working with distributed applications like offline mobile apps.
I guess to summaries what Iâm saying is Iâm after a stable, non sensitive LastEvaluatedKey that canât be used to comprise the system.Tyler Walch
04/30/2022, 12:26 AMTyler Walch
04/30/2022, 12:28 AMJono Allen
04/30/2022, 10:48 PM