Today I Learned

hashrocket A Hashrocket project

Exclude parts of a query in Ecto

Ecto.Query has a function called exclude you can call it to remove previous parts of a query that have already been defined

query = from(u in User,
  where: u.email == "jack@example.com",
  select: u.email

query
|> exclude(:where)
#=> will return the %Ecto.Query{} expression without the where clause
See More #elixir TILs
Looking for help? At Hashrocket, we 💜 Elixir! From our many Elixir client projects, to sponsoring the Chicago Elixir Meetup, to the source code for this application, we are invested in this community. Contact us today to talk about your Elixir project.