I am new to using Ecto and Elixir and I have encountered an error that I cannot explain. My code looks the same as in the example in Ecto README.
Here are my modules for Ecto Model and Query
defmodule Registration do
use Ecto.Model
schema "registrations" do
field :user_id, :string
field :created_at, :datetime, default: Ecto.DateTime.local
field :updated_at, :datetime, default: Ecto.DateTime.local
end
end
defmodule RegistrationQuery do
import Ecto.Query
def by_user(user_id) do
query = from r in Registration,
where: r.user_id == ^user_id,
select: r
Repo.all(query)
end
end
This is how I call the request function
registrations = Repo.all RegistrationQuery.by_user("underwater")
All this is similar to the Ecto documentation, and I cannot find anything, to put it another way. But I get the following error.
protocol Ecto.Queryable not implemented for [%Ensalutilo.Registration{user_id: "underwater"}]
source
share