I'm very new in the world of Elixir and Phoenix Framework. I'm trying to follow TheFireHoseProject tutorial, but having problems with querying raw SQL with Ecto. The tutorial says this should work:
defmodule Queries do
def random do
query = Ecto.Adapters.Postgres.query(
Repo,
"SELECT id, saying, author from quotes ORDER BY RANDOM() LIMIT 1",
[])
%Postgrex.Result{rows: [row]} = query
{id, saying, author} = row
%Splurty.Quote{id: id, saying: saying, author: author}
end
end
I'm getting a runtime error that the Ecto.Adapters.Postgres.query doesn't exist (undefined function).
I tried to search the Ecto documentation and found that there might be a function called run_query, but it doesn't work either.
I think I'm using Ecto 1.1.4 and I didn't find any good (up-to-date) samples of how can I query raw SQL with Ecto.
The link to the firehoseproject is: http://phoenix.thefirehoseproject.com/