0
でクエリを作成しようとしていたとき、私はエリクシールで初心者だし、私は、クエリを作成しようとしている「変数が存在しない」:私はエクト
def posts_liked(%{id: id}, _info) do
query = from u in Like, where: u.user_id == ^id
{:ok, Repo.all(query)}
end
しかし、と言います変数u
は存在しません。しかし、in oficial docにはこのコードと他のマニュアルもあります。それを修正するには?
私Like
スキームは次のとおりです。
schema "likes" do
belongs_to :post, Myapp.Post, foreign_key: :post_id
belongs_to :user, Myapp.User, foreign_key: :user_id
timestamps()
end
このモジュールに 'import Ecto.Query'がありますか? – Dogbert