Apply changes from changeset to a record fetched via

I have a requirement where I am receiving a changeset in a function and if a record exists in a table, that changeset should apply to that record. Whats the best possible way. I can do for example
cast(record, changeset.changes)
is this the best way to achieve the desired result?

Since you’ve already got a changeset (presumably with cast and validations etc) you could use Ecto.Changeset.change/2:

Ecto.Changeset.change(struct, changeset.change)