Elixir + Ecto: How to do WHERE NOT IN [array]?

I am trying to find all User that do not have a specific string element in their match_history field. I suggested that:

matched_user = User |> where([u], ^device_id not in u.match_history) |> limit(1) |> VideoChat.Repo.one

But he seems to be breaking up into the not part. Is there any way to do this?

+7
elixir ecto
source share
1 answer

Try

User |> where([u], not ^device_id in u.match_history)

+9
source share

All Articles