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
Hey folks, I’ve been using Elixir for over a couple of years (phx, ecto, broadway, oban).
For this kind of work you do not tend, in my e...
New
Hi, I’m Dheeraj Sudan from the UK. I’m a software developer and also run a business with my wife Meenu Hinduja. I’m interested in getting...
New
Other Trending Topics
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New
There are three potential reasons for members of this forum to have a look at https://vutuv.de
You are tired or annoyed of LinkedIn.
Yo...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #blog-post
- #phoenix_html
- #iex
- #graphql
- #ai
- #genstage
- #elixirconf-us
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex










First 10 of 31 Posts
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