Select all Table Entries based on a Field Value and Update Them

From ElixirBlocks
Jump to: navigation, search

Example


 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

With pub sub incorporated

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