Ash and MySQL ?

Hi, I've just discovered Ash, and it looks very interesting. In particular I love the idea of a declarative data model representation. However I've a problem : Im' in an environment where I must use MySQL (well... a Percona xtradb cluster actually). Is it possible to use Ash with MySQL ? Is there a data layer for MySQL (didn't find one) ? Is Ash usable with a db bu twithout a data layer ? Or even, how much work would it be to make a MySQL data layer for Ash ? Thanks in advance.
1 Reply
ZachDaniel
ZachDaniel3y ago
We do not have MySQL data layer yet, but it’s on the roadmap 🙂 making a data layer for it shouldn’t be too difficult by basing it in ash postgres, but likely difficult for a newcomer to Ash. Ash can be used without a data layer. Certain features may be missed out on though or would be harder to use because they must be implemented manually. But you could do something like this:
defmodule MyResourceInMySQL do
use Ash.Resource
import Ecto.Query, only: [from: 2]

actions do
read :read do
manual fn query, _ ->
# you can implement query tooling on your own if you like
# it will eventually be provided for you.
ecto_query =
from row in {"table_name", __MODULE__},
...


{:ok, MySqlRepo.all(ecto_query)}
end
end
end
end
defmodule MyResourceInMySQL do
use Ash.Resource
import Ecto.Query, only: [from: 2]

actions do
read :read do
manual fn query, _ ->
# you can implement query tooling on your own if you like
# it will eventually be provided for you.
ecto_query =
from row in {"table_name", __MODULE__},
...


{:ok, MySqlRepo.all(ecto_query)}
end
end
end
end

Did you find this page helpful?