4
저는 Ecto와 Elixir를 처음 사용하기 때문에 설명 할 수없는 오류가 발생했습니다. 내 코드는 Ecto README의 예제와 같습니다. 여기수정 프로토콜 Ecto.Queryable 구현되지 않은 오류
체외 모델 및 쿼리 여기
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
내 모듈은 I 쿼리 기능을
registrations = Repo.all RegistrationQuery.by_user("underwater")
이를 호출하는 방법을 모두 정확히 체외 문서와 일치 보인다, 그리고 내가 할 수있는 다르게 말하는 것을 발견하지 못합니다. 하지만 다음 오류가 발생합니다.
protocol Ecto.Queryable not implemented for [%Ensalutilo.Registration{user_id: "underwater"}]