Skip to content

Commit abc1624

Browse files
authored
Update docs, remove Multi guide (#4619)
1 parent be60b77 commit abc1624

File tree

6 files changed

+20
-316
lines changed

6 files changed

+20
-316
lines changed

guides/howtos/Composable transactions with Multi.md

Lines changed: 0 additions & 299 deletions
This file was deleted.

guides/howtos/Data mapping and validation.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,10 @@ if changeset.valid? do
7474
account = Registration.to_account(registration)
7575
profile = Registration.to_profile(registration)
7676

77-
MyApp.Repo.transaction fn ->
78-
MyApp.Repo.insert_all "accounts", [account]
79-
MyApp.Repo.insert_all "profiles", [profile]
80-
end
77+
MyApp.Repo.transact(fn ->
78+
MyApp.Repo.insert_all("accounts", [account])
79+
MyApp.Repo.insert_all("profiles", [profile])
80+
end)
8181

8282
{:ok, registration}
8383
else

lib/ecto.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,14 +340,14 @@ defmodule Ecto do
340340
Another function in `Ecto` is `build_assoc/3`, which allows
341341
someone to build an associated struct with the proper fields:
342342
343-
Repo.transaction fn ->
343+
Repo.transact(fn ->
344344
post = Repo.insert!(%Post{title: "Hello", body: "world"})
345345
346346
# Build a comment from post
347347
comment = Ecto.build_assoc(post, :comments, body: "Excellent!")
348348
349349
Repo.insert!(comment)
350-
end
350+
end)
351351
352352
In the example above, `Ecto.build_assoc/3` is equivalent to:
353353

lib/ecto/multi.ex

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@ defmodule Ecto.Multi do
1818
`Ecto.Multi.to_list/1` returns a canonical representation of the
1919
structure that can be used for introspection.
2020
21+
> #### When to use Ecto.Multi? {: .info}
22+
23+
> `Ecto.Multi` is particularly useful when the set of operations to perform
24+
> is dynamic. For most use cases, however, using regular control flow within
25+
> [`Repo.transact(fun)`](`c:Ecto.Repo.transact/2`) and returning
26+
> `{:ok, result}` or `{:error, reason}` is more straightforward.
27+
2128
## Changesets
2229
2330
If multi contains operations that accept changesets (like `insert/4`,

0 commit comments

Comments
 (0)