View Source Quarto.Cursor.Encode protocol (Quarto v1.1.7)

Protocol for encoding individual cursor values.

E.g. some values are overly lengthy when encoding with the default way, implementing a custom protocol can cut that down

defimpl Quarto.Cursor.Encode, for: DateTime do
  def convert(term), do: {"dt", DateTime.to_unix(term, :microsecond)}
end

defimpl Quarto.Cursor.Decode, for: Tuple do
  def convert({"dt", unix_timestamp}), do: DateTime.from_unix!(unix_timestamp, :microsecond)
end

See https://github.com/duffelhq/paginator/pull/62 for a helpful issue

Link to this section Summary

Functions

Converts the term to a single cursor value

Link to this section Types

Link to this section Functions

Converts the term to a single cursor value