Skip to content

Commit

Permalink
clarify docs
Browse files Browse the repository at this point in the history
  • Loading branch information
greg-rychlewski committed Nov 3, 2024
1 parent a54d96f commit b415e64
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion guides/howtos/Data mapping and validation.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ end

In the example above, by breaking apart the mapping between the database and Elixir and between Elixir and the UI, our code becomes clearer and our data structures simpler.

Note we have used `MyApp.Repo.insert_all/2` to add data to both "accounts" and "profiles" tables directly. We have chosen to bypass schemas altogether. However, there is nothing stopping you from also defining both `Account` and `Profile` schemas and changing `to_account/1` and `to_profile/1` to respectively return `%Account{}` and `%Profile{}` structs. Once structs are returned, they could be inserted through the usual `MyApp.Repo.insert/2` operation. Doing so can be especially useful if there are uniqueness or other constraints that you want to check during insertion.
Note we have used `MyApp.Repo.insert_all/2` to add data to both "accounts" and "profiles" tables directly. We have chosen to bypass schemas altogether. However, there is nothing stopping you from also defining both `Account` and `Profile` schemas and changing `to_account/1` and `to_profile/1` to respectively return `%Account{}` and `%Profile{}` structs. Once structs are returned, they could be inserted through the usual `MyApp.Repo.insert/2` operation. One can also check for uniqueness or other constraints during insertion by using the structs in a changeset.

## Schemaless changesets

Expand Down

0 comments on commit b415e64

Please sign in to comment.