User: Admin: Difference between revisions

From ElixirBlocks
Jump to: navigation, search
No edit summary
No edit summary
Line 14: Line 14:


Note:
Note:
 
<pre>
defmodule AppWeb.PageLive do
defmodule AppWeb.PageLive do
   use AppWeb, :live_view   
   use AppWeb, :live_view   
Line 35: Line 35:


end
end
</pre>
__________________________________________________
__________________________________________________



Revision as of 20:51, 4 June 2023

  • How to Create Database Seed Data.
  • How to Use Generators in a Real World Project
  • How to Work with Database Data via Basic Commands and Custom Change sets.
  • How to Render Database Data to LiveView (via Context Commands).
  • How to Create a Chat using PubSub.
  • How to Create Event Handlers in LiveView
  • How to Create a Dynamic Route from Scratch.
  • How to Use Elixirs Template language
  • How to Work with Modal
  • How to Use CSS From Scratch (Without bundler)
  • How to use JS hooks

_________________________________________________

Note:

defmodule AppWeb.PageLive do
   use AppWeb, :live_view  
   alias App.Alerts
   def mount(_params, _session, socket)  do
	 {:ok, assign(socket, alerts: Alerts.list_alerts())}  
   end

   def render(assigns) do
     ~H"""
        <%= for alert <- @alerts do %>
        	<%= if alert.enabled  do %>
              <div><%= alert.content%></div>
              <% end %>

        <% end %>

	 """ 
   end

end

__________________________________________________

Complex pattern matching https://www.youtube.com/watch?v=gCVWrM5BNVE

Genservers (and related, agent,task etc)


__________________________________________________

ECTO

query = from "artists", select:[:name]

Verbose:

Ecto.Query.from("artists", select[:name])


Repo.all(query)

  1. => [%{name: "Miles Davis"}, %{name: "Bill Evans"}]



Repo.to_sql(:all, query)