chris-menz

chris-menz

Help with Ecto.Multi

Hello,

I am attempting to use Ecto.multi for the first time to create related records. I have two tables, spot_conditions and spots. Spots belongs to spot_conditions. So i am trying to use ecto.multi to create both as following.




No spot is created, that is the output when trying to call the function. Not sure how to debug from here, any help would be greatly appreciated!

Marked As Solved

joey_the_snake

joey_the_snake

It looks like you are building the multi but not executing it. You just need to pass the finished multi into Repo.transaction in order to have it executed. Calling the multi functions themselves will just build up the commands you want to run but not actually execute them.

Also Liked

benwilson512

benwilson512

Author of Craft GraphQL APIs in Elixir with Absinthe

Hey @chris-menz I’m glad the issue was solved! As a minor note, please copy and paste text in the future instead of using screenshots. It’s a lot more accessible to different screen sizes, and also makes it easier for people to suggest small edits by copying, pasting, and editing the code.

Last Post!

benwilson512

benwilson512

Author of Craft GraphQL APIs in Elixir with Absinthe

Hey @chris-menz I’m glad the issue was solved! As a minor note, please copy and paste text in the future instead of using screenshots. It’s a lot more accessible to different screen sizes, and also makes it easier for people to suggest small edits by copying, pasting, and editing the code.

Where Next?

Popular in Questions Top

hariharasudhan94
lets say i have a sample like a = 20; b = 10; if (a > b) do {:ok, "a"} end if (a < b) do {:ok, b} end if (a == b) do {:ok, "equa...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? Ecto.Repo — Ecto v3.14.0 has exampl...
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New

Other popular topics Top

Qqwy
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
AngeloChecked
What learn first? Rust or Elixir Hi Elixir community! I’m here because i want learn a new language. I’m a junior developer and mainly i ...
New

We're in Beta

About us Mission Statement