Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Implement Paginator.Cursor in a more configurable way #61

Open
fuelen opened this issue Apr 2, 2019 · 0 comments
Open

Implement Paginator.Cursor in a more configurable way #61

fuelen opened this issue Apr 2, 2019 · 0 comments

Comments

@fuelen
Copy link

fuelen commented Apr 2, 2019

Use case: encode/decode DateTime in a shorter variant, like Unix timestamp or so.

Example:

a = DateTime.utc_now                              
#DateTime<2019-04-02 11:43:12.567049Z>
a |> :erlang.term_to_binary() |> Base.url_encode64()
"g3QAAAANZAAKX19zdHJ1Y3RfX2QAD0VsaXhpci5EYXRlVGltZWQACGNhbGVuZGFyZAATRWxpeGlyLkNhbGVuZGFyLklTT2QAA2RheWECZAAEaG91cmELZAALbWljcm9zZWNvbmRoAmIACKcJYQZkAAZtaW51dGVhK2QABW1vbnRoYQRkAAZzZWNvbmRhDGQACnN0ZF9vZmZzZXRhAGQACXRpbWVfem9uZW0AAAAHRXRjL1VUQ2QACnV0Y19vZmZzZXRhAGQABHllYXJiAAAH42QACXpvbmVfYWJicm0AAAADVVRD"
a |> DateTime.to_unix(:microsecond) |> :erlang.term_to_binary |> Base.url_encode64()
"g24HAA27XHaShQU="

As you can see, the latter is much shorter.

@fuelen fuelen changed the title Implement Paginator.Cursor as a protocol Implement Paginator.Cursor in a more configurable way Apr 2, 2019
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant