Working with Ecto: Difference between revisions

From ElixirBlocks
Jump to: navigation, search
(Created page with " {{In_progress}} https://brooklinmyers.medium.com/ecto-with-phoenix-in-4-minutes-9b7c447055c6")
 
No edit summary
Line 4: Line 4:


https://brooklinmyers.medium.com/ecto-with-phoenix-in-4-minutes-9b7c447055c6
https://brooklinmyers.medium.com/ecto-with-phoenix-in-4-minutes-9b7c447055c6
==Update all tables that contain a field with a chosen value==
<source>
  def reset_testbeds do
    items = from t in TestBed, where: t.status == "Taken"
    Repo.update_all(items, set: [status: "Available", developer: "None"])
    |> broadcast_change([:testbed, :reset])
  end
 
</source>

Revision as of 16:08, 3 June 2023

This page is in progress


https://brooklinmyers.medium.com/ecto-with-phoenix-in-4-minutes-9b7c447055c6


Update all tables that contain a field with a chosen value

   def reset_testbeds do
    items = from t in TestBed, where: t.status == "Taken"
    Repo.update_all(items, set: [status: "Available", developer: "None"])
    |> broadcast_change([:testbed, :reset])
  end