How can I convert an Elixir value to SQL format using Postgrex?

161 Views Asked by At

For example, let's say I have a Postgrex date value ~D[2017-11-28]. I'd like to pass that to a hypothetical Postgrex function Postgrex.hypothetical_format_to_sql that will return something like "2017-11-28" (ie, the same data but in PostgreSQL format instead of as Elixir data).

Ideally, it takes an arbitrary Elixir value and formats it into a Postgres datum. I strongly suspect something like this exists in Postgrex. I read this (https://hexdocs.pm/postgrex/Postgrex.Extension.html#callbacks) and it mentions encode(state) but it isn't clear if that does what I'm trying to do (it appears most likely not)

If anyone has advice on how I can go about this it's immensely appreciated. Thanks!

0

There are 0 best solutions below