How to Iterate and Render Database Data in Phoenix LiveView
From ElixirBlocks
This page is in progress
Before You Begin
Installing Phoenix
This article assumes that you have installed the Phoenix web framework and all its dependencies correctly without errors. If you have not installed the Phoenix web framework please view the documentation here
Example
This code references a PostgreSQL table named TestBeds.
use AppWeb, :live_view alias App.TestBeds defmodule AppWeb.PageLive do use AppWeb, :live_view alias App.TestBeds def mount(_params, _session, socket) do {:ok, assign(socket, testbeds: TestBeds.list_testbeds())} end def render(assigns) do ~H""" <%= for testbed <- assigns.testbeds do %> <div><%= testbed.name %></div> <% end %> """ end end