I just want to run a basic DB table update

I have a basic Phoenix app. All I want to do is run a basic update to a DB table that changes a value

testbed = {name: “value”} # old
testbed {name: “new value”} # new

My Schema

defmodule App.TestBeds.TestBed do
  use Ecto.Schema
  import Ecto.Changeset

  schema "test_beds" do
    field :name, :string
    field :note, :string
    field :version, :string
    field :status_id, :id

    timestamps()
  end

  @doc false
  def changeset(test_bed, attrs) do
    test_bed
    |> cast(attrs, [:name, :version, :note])
    |> validate_required([:name, :version, :note])
  end
end

defmodule App.TestBeds do
  @moduledoc """
  The TestBeds context.
  """

  import Ecto.Query, warn: false
  alias App.Repo

  alias App.TestBeds.TestBed

  # Bunch of REPO methods

  #__________________I tried to import the changeset method and do this:

  def do_thing() do 
     
     
     item = Repo.get_by(TestBed,name: "Grindy")
     Testbed.changeset(item, %{name: "We Are The World"})
     |> Repo.update

  end

#________________________________ It didn't work. 
end

The documentation is a brick of text so I gave up on that one.

I found this which seems to be more helpful , but I am unsure where (or exactly how) to run changesets:

I just want to see a working example in context.

Thank you

What you’ve posted looks reasonable; what was the error message when it didn’t work?

|> IO.inspect is your friend.

I figured it out


selected_testbed = TestBeds.get_by(%{name: "Grindy"})   
  
TestBeds.update_test_bed(selected_testbed, %{name: "WHATEVER"})