Postgrex/Ecto custom operators in queries for custom types

Can’t google any info on the subject. Is there a way to implement custom operators, for example, for ltree extension?

I would like to use it in queries in this way

from o in "objects",
          where: o.path ~ "some.lquery.*",
          select: o.content

SELECT content FROM objects WHERE path ~ 'some.lquery.*';

You cannot add custom operators, but you can use fragments + macros to add custom “functions” to the query api.
https://hexdocs.pm/ecto/3.1.4/Ecto.Query.API.html#fragment/1

2 Likes

yep, works too, thanks