@@ -61,7 +61,7 @@ defmodule Ecto.Multi do
6161
6262 We can later execute it in the integration layer using Repo:
6363
64- Repo.transaction (PasswordManager.reset(account, params))
64+ Repo.transact (PasswordManager.reset(account, params))
6565
6666 By pattern matching on the result we can differentiate different conditions:
6767
@@ -253,7 +253,7 @@ defmodule Ecto.Multi do
253253 Ecto.Multi.new()
254254 |> Ecto.Multi.insert(:comment, Ecto.build_assoc(post, :comments))
255255 end)
256- |> MyApp.Repo.transaction ()
256+ |> MyApp.Repo.transact ()
257257 """
258258 @ spec merge ( t , ( changes -> t ) ) :: t
259259 def merge ( % Multi { } = multi , merge ) when is_function ( merge , 1 ) do
@@ -286,14 +286,14 @@ defmodule Ecto.Multi do
286286
287287 Ecto.Multi.new()
288288 |> Ecto.Multi.insert(:insert, %Post{title: "first"})
289- |> MyApp.Repo.transaction ()
289+ |> MyApp.Repo.transact ()
290290
291291 Ecto.Multi.new()
292292 |> Ecto.Multi.insert(:post, %Post{title: "first"})
293293 |> Ecto.Multi.insert(:comment, fn %{post: post} ->
294294 Ecto.build_assoc(post, :comments)
295295 end)
296- |> MyApp.Repo.transaction ()
296+ |> MyApp.Repo.transact ()
297297
298298 """
299299 @ spec insert (
@@ -329,14 +329,14 @@ defmodule Ecto.Multi do
329329 changeset = Ecto.Changeset.change(post, title: "New title")
330330 Ecto.Multi.new()
331331 |> Ecto.Multi.update(:update, changeset)
332- |> MyApp.Repo.transaction ()
332+ |> MyApp.Repo.transact ()
333333
334334 Ecto.Multi.new()
335335 |> Ecto.Multi.insert(:post, %Post{title: "first"})
336336 |> Ecto.Multi.update(:fun, fn %{post: post} ->
337337 Ecto.Changeset.change(post, title: "New title")
338338 end)
339- |> MyApp.Repo.transaction ()
339+ |> MyApp.Repo.transact ()
340340
341341 """
342342 @ spec update ( t , name , Changeset . t ( ) | fun ( Changeset . t ( ) ) , Keyword . t ( ) ) :: t
@@ -362,7 +362,7 @@ defmodule Ecto.Multi do
362362 changeset = Post.changeset(%Post{}, %{title: "New title"})
363363 Ecto.Multi.new()
364364 |> Ecto.Multi.insert_or_update(:insert_or_update, changeset)
365- |> MyApp.Repo.transaction ()
365+ |> MyApp.Repo.transact ()
366366
367367 Ecto.Multi.new()
368368 |> Ecto.Multi.run(:post, fn repo, _changes ->
@@ -371,7 +371,7 @@ defmodule Ecto.Multi do
371371 |> Ecto.Multi.insert_or_update(:update, fn %{post: post} ->
372372 Ecto.Changeset.change(post, title: "New title")
373373 end)
374- |> MyApp.Repo.transaction ()
374+ |> MyApp.Repo.transact ()
375375
376376 """
377377 @ spec insert_or_update ( t , name , Changeset . t ( ) | fun ( Changeset . t ( ) ) , Keyword . t ( ) ) :: t
@@ -406,7 +406,7 @@ defmodule Ecto.Multi do
406406 post = MyApp.Repo.get!(Post, 1)
407407 Ecto.Multi.new()
408408 |> Ecto.Multi.delete(:delete, post)
409- |> MyApp.Repo.transaction ()
409+ |> MyApp.Repo.transact ()
410410
411411 Ecto.Multi.new()
412412 |> Ecto.Multi.run(:post, fn repo, _changes ->
@@ -419,7 +419,7 @@ defmodule Ecto.Multi do
419419 # Others validations
420420 post
421421 end)
422- |> MyApp.Repo.transaction ()
422+ |> MyApp.Repo.transact ()
423423
424424 """
425425 @ spec delete (
@@ -456,7 +456,7 @@ defmodule Ecto.Multi do
456456 |> Ecto.Multi.one(:author, fn %{post: post} ->
457457 from(a in Author, where: a.id == ^post.author_id)
458458 end)
459- |> MyApp.Repo.transaction ()
459+ |> MyApp.Repo.transact ()
460460 """
461461 @ spec one (
462462 t ,
@@ -485,11 +485,11 @@ defmodule Ecto.Multi do
485485
486486 Ecto.Multi.new()
487487 |> Ecto.Multi.all(:all, Post)
488- |> MyApp.Repo.transaction ()
488+ |> MyApp.Repo.transact ()
489489
490490 Ecto.Multi.new()
491491 |> Ecto.Multi.all(:all, fn _changes -> Post end)
492- |> MyApp.Repo.transaction ()
492+ |> MyApp.Repo.transact ()
493493 """
494494 @ spec all (
495495 t ,
@@ -518,11 +518,11 @@ defmodule Ecto.Multi do
518518
519519 Ecto.Multi.new()
520520 |> Ecto.Multi.exists?(:post, Post)
521- |> MyApp.Repo.transaction ()
521+ |> MyApp.Repo.transact ()
522522
523523 Ecto.Multi.new()
524524 |> Ecto.Multi.exists?(:post, fn _changes -> Post end)
525- |> MyApp.Repo.transaction ()
525+ |> MyApp.Repo.transact ()
526526 """
527527 @ spec exists? (
528528 t ,
@@ -614,7 +614,7 @@ defmodule Ecto.Multi do
614614 posts = [%{title: "My first post"}, %{title: "My second post"}]
615615 Ecto.Multi.new()
616616 |> Ecto.Multi.insert_all(:insert_all, Post, posts)
617- |> MyApp.Repo.transaction ()
617+ |> MyApp.Repo.transact ()
618618
619619 Ecto.Multi.new()
620620 |> Ecto.Multi.run(:post, fn repo, _changes ->
@@ -631,7 +631,7 @@ defmodule Ecto.Multi do
631631 Map.put(comment, :post_id, post.id)
632632 end)
633633 end)
634- |> MyApp.Repo.transaction ()
634+ |> MyApp.Repo.transact ()
635635
636636 """
637637 @ spec insert_all (
@@ -662,7 +662,7 @@ defmodule Ecto.Multi do
662662
663663 Ecto.Multi.new()
664664 |> Ecto.Multi.update_all(:update_all, Post, set: [title: "New title"])
665- |> MyApp.Repo.transaction ()
665+ |> MyApp.Repo.transact ()
666666
667667 Ecto.Multi.new()
668668 |> Ecto.Multi.run(:post, fn repo, _changes ->
@@ -675,7 +675,7 @@ defmodule Ecto.Multi do
675675 # Others validations
676676 from(c in Comment, where: c.post_id == ^post.id, update: [set: [title: "New title"]])
677677 end, [])
678- |> MyApp.Repo.transaction ()
678+ |> MyApp.Repo.transact ()
679679
680680 """
681681 @ spec update_all (
@@ -707,7 +707,7 @@ defmodule Ecto.Multi do
707707 queryable = from(p in Post, where: p.id < 5)
708708 Ecto.Multi.new()
709709 |> Ecto.Multi.delete_all(:delete_all, queryable)
710- |> MyApp.Repo.transaction ()
710+ |> MyApp.Repo.transact ()
711711
712712 Ecto.Multi.new()
713713 |> Ecto.Multi.run(:post, fn repo, _changes ->
@@ -720,7 +720,7 @@ defmodule Ecto.Multi do
720720 # Others validations
721721 from(c in Comment, where: c.post_id == ^post.id)
722722 end)
723- |> MyApp.Repo.transaction ()
723+ |> MyApp.Repo.transact ()
724724
725725 """
726726 @ spec delete_all ( t , name , Ecto.Queryable . t ( ) | fun ( Ecto.Queryable . t ( ) ) , Keyword . t ( ) ) :: t
@@ -781,7 +781,7 @@ defmodule Ecto.Multi do
781781 |> Ecto.Multi.put(:company, company)
782782 |> Ecto.Multi.insert(:user, fn changes -> User.changeset(changes.company) end)
783783 |> Ecto.Multi.insert(:person, fn changes -> Person.changeset(changes.user, changes.company) end)
784- |> MyApp.Repo.transaction ()
784+ |> MyApp.Repo.transact ()
785785
786786 In the example above there isn't a large benefit in putting the
787787 `company` in the multi, because you could also access the
@@ -817,7 +817,7 @@ defmodule Ecto.Multi do
817817 |> Ecto.Multi.insert(:person_a, changeset)
818818 |> Ecto.Multi.insert(:person_b, changeset)
819819 |> Ecto.Multi.inspect()
820- |> MyApp.Repo.transaction ()
820+ |> MyApp.Repo.transact ()
821821
822822 Prints:
823823 %{person_a: %Person{...}, person_b: %Person{...}}
@@ -828,7 +828,7 @@ defmodule Ecto.Multi do
828828 |> Ecto.Multi.insert(:person_a, changeset)
829829 |> Ecto.Multi.insert(:person_b, changeset)
830830 |> Ecto.Multi.inspect(only: :person_a)
831- |> MyApp.Repo.transaction ()
831+ |> MyApp.Repo.transact ()
832832
833833 Prints:
834834 %{person_a: %Person{...}}
0 commit comments