Understanding Ecto query writing

If we go back and look at the list_poll() function that we just wrote, you can see that we have the Repo.all/1 query and that it gets passed into a Repo.preload/1 statement. Without really understanding what's going on here, this is all just going to feel a bit like magic. Nothing in Elixir should ever just be reduced to magic, so let's take a peek behind the curtains, so to speak.

In this case, when we call Repo.all, we're just passing it the name of the schema. If we run h Vocial.Repo.all in our IEx terminal, we'll see something like the following:

iex(2)> h Vocial.Repo.all@callback all(queryable :: Ecto.Query.t(), opts :: Keyword.t()) :: [Ecto.Schema.t()] | no_return()Fetches all entries from the data store ...

Get Phoenix Web Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.