Phoenix Query Get First Record

[Solved] Phoenix Query Get First Record | Elixir - Code Explorer | yomemimo.com
Question : phoenix query get first record

Answered by : nguyen-quang-huy

iex> Movie |> first() |> Repo.one()
SELECT m0."id", m0."title", m0."tagline" FROM "movies" AS m0 ORDER BY m0."id" LIMIT 1 []
%Friends.Movie{ __meta__: #Ecto.Schema.Metadata<:loaded, "movies">, actors: #Ecto.Association.NotLoaded<association :actors is not loaded>, characters: #Ecto.Association.NotLoaded<association :characters is not loaded>, distributor: #Ecto.Association.NotLoaded<association :distributor is not loaded>, id: 1, tagline: "Something about video games", title: "Ready Player One"
}

Source : https://elixirschool.com/en/lessons/ecto/querying_basics | Last Update : Fri, 07 Jan 22

Answers related to phoenix query get first record

Code Explorer Popular Question For Elixir