Last active
April 3, 2021 18:45
-
-
Save rhiroyuki/5abbe94ec1b72b4acfbc54ed166cfad2 to your computer and use it in GitHub Desktop.
Revisions
-
rhiroyuki revised this gist
Apr 3, 2021 . 1 changed file with 14 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -49,3 +49,17 @@ iex -S mix phx.server ``` # recompile ``` ### Scaffold ``` $ mix phx.gen.context Todos Todo todos title:string done:boolean * creating lib/live_view_todos/todos/todo.ex * creating priv/repo/migrations/20210403184352_create_todos.exs * creating lib/live_view_todos/todos.ex * injecting lib/live_view_todos/todos.ex * creating test/live_view_todos/todos_test.exs * injecting test/live_view_todos/todos_test.exs ``` -
rhiroyuki revised this gist
Apr 2, 2021 . 1 changed file with 6 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -43,3 +43,9 @@ Run the server with the following command: ``` iex -S mix phx.server ``` ### Reloading ``` # recompile ``` -
rhiroyuki revised this gist
Mar 25, 2020 . 1 changed file with 6 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -28,6 +28,12 @@ User.last Repo.one(from x in Model, order_by: [desc: x.id], limit: 1) ``` ## Querying ``` Repo.all(from x in SomeModel, where: x.greeted == true) ``` ## Prying ``` require IEx; IEx.pry -
rhiroyuki revised this gist
Mar 24, 2020 . 1 changed file with 9 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -28,3 +28,12 @@ User.last Repo.one(from x in Model, order_by: [desc: x.id], limit: 1) ``` ## Prying ``` require IEx; IEx.pry ``` Run the server with the following command: ``` iex -S mix phx.server ``` -
rhiroyuki revised this gist
Feb 20, 2020 . 1 changed file with 6 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -16,12 +16,15 @@ Repo.one(from x in Model, limit: 1) ``` Getting the last record ### ActiveRecord ``` User.last ``` ### Ecto ``` Repo.one(from x in Model, order_by: [desc: x.id], limit: 1) ``` -
rhiroyuki revised this gist
Feb 20, 2020 . 1 changed file with 6 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,13 +1,17 @@ ## Ecto Getting the first record ### In ActiveRecord ``` User.first ``` ### In Ecto ``` Repo.one(from x in Model, order_by: [asc: x.id], limit: 1) # You can hide the order_by since it is ascending by default Repo.one(from x in Model, limit: 1) ``` -
rhiroyuki created this gist
Feb 20, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,23 @@ ## Ecto Getting the first record ``` # ActiveRecord User.first ``` ``` # Ecto Repo.one(from x in Model, order_by: [asc: x.id], limit: 1) Repo.one(from x in Model, limit: 1) ``` Getting the last record ``` # ActiveRecord User.last ``` ``` # Ecto Repo.one(from x in Model, order_by: [desc: x.id], limit: 1) ```