How to rewrite this function in pipelines?

Hello. I would like to rewrite from() in pipelines.

    from(
      t in Tournament,
      where: like(t.name, ^like) or like(t.game_name, ^like)
    )
    |> date_filter()
    |> Repo.all()

Is it possible?

I think from the top of my head that you could do:

# assuming
import Ecto.Query

t in Tournament
|> from()
|> where(like(t.name, ^like) or like(t.game_name, ^like))
|> date_filter()
|> Repo.all()
1 Like

I think it’s more like this:

import Ecto.Query, only: [where: 3]

Tournament
|> where([t], like(t.name, ^like) or like(t.game_name, ^like))
|> date_filter()
|> Repo.all()

See Ecto.Query — Ecto v3.7.1

1 Like

Thank you!