Adding Postgres-specific functionality to Ecto

Is there a guide floating around for extending Ecto, like say, adding the ltree extension for Postgres? If it is already in their docs then I am sorry, I could not find it.

I know that there are already one or two libraries floating around, but I would like to use Ecto and be as close to the original SQL statements as I understand them.

You need to do it in two steps:

  1. First is to implement a Postgrex extension so you can convert the data encoded by Postgres into Elixir types

  2. Then you implement a custom Ecto type so you tell Ecto how to load, dump, cast, this data.

I recommend looking at existing libraries that extends Ecto the way you want for example, such as: https://github.com/bryanjos/geo_postgis

Thank you! Will do.

1 Like