wolfiton
I have the following function that I want to rewrite using the defp
def list_items(%{matching: name}) when is_binary(name) do
Item
|> where([m], ilike(m.name, ^"%#{name}%"))
|> Repo.all()
end
What I tried
def list_items(%{matching: name}) when is_binary(name) do
Item
|> search(term)
|> Repo.all()
end
defp search(term) do
term
|> from t in Item
|> where([t], ilike(t.name, ^"%#{term}%"))
end
Can someone explain how to do this?
from` must be a compile time keyword list
Shouldn’t Item work here?
Thanks
Trending in Chat/Questions
Other Trending Topics
Edit: 2026 May 15 - This post is archived.
Mob is alive!!
Main docs: mob v0.7.11 — Documentation
A bit of explanation for the slightly c...
New
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
A little off-topic, but I feel like people here have a good head on their shoulders.
I used to be quite good at making software. Was luc...
New
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #ai
- #podcasts-by-brainlid
- #ecto-query
- #blog-post
- #elixirconf-us
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #elixirconf-eu
- #api
- #forms
- #security
- #metaprogramming











Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
benwilson512
This isn’t a valid way to use from, it expands to
from(term, t in Item)since|>puts arguments at the front.wolfiton
What can I pipe it through?
Kurisu
When you’re using
fromyou don’t pipe.See this topic:
wolfiton
This works
But I get a dializer error with unused query variable. Is there a better way to do this?
benwilson512
You can’t pipe into from. The ecto docs contain examples of how to use pipe with where, you don’t need to use from.
wolfiton
I couldn’t think of another way that is why, I am asking.
I also read through the docs.
tenzil
Hi , I kind of did this for my requirement. hope it helps you,
wolfiton
Thanks but i am trying to keep the public fn clean and use only pipes there and do the actual work in private fn.
tenzil
How about this
wolfiton
Interesting, I am now wondering if if can keep and do