Insert into Database without Form
Is there a way to insert into the database a new entry without a form.
i.e. a user does a form action which creates an entity and then I need to update the user to attach them to that new entity.
7 Replies
By entry, do you mean to insert a resource?
yeah
Have you use Ash outside the context of phoenix forms so far?
A little
But I wondered if there was a flow syntax
There is an
Ash.Flow
which will run a series of steps, but you can also just invoke actions directly
i.e user |> Ash.Changeset.for_update(...) |> Api.update!()
and if you want to do it in an action (i.e relate the current actor)
then you can create the form with the current user, i.e Form.for_create(..., actor: socket.assigns.current_user)
cool thanks
sorry for the delayed reply I have been busy with other stuff and not had chance to look at this since
Not a problem 🙂 you do what you gotta do 😁