From b415e641381fd42391fe5d5550756a692e057a92 Mon Sep 17 00:00:00 2001 From: Greg Date: Sun, 3 Nov 2024 07:02:24 -0500 Subject: [PATCH] clarify docs --- guides/howtos/Data mapping and validation.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/guides/howtos/Data mapping and validation.md b/guides/howtos/Data mapping and validation.md index 4dca7d979f..f79f16db16 100644 --- a/guides/howtos/Data mapping and validation.md +++ b/guides/howtos/Data mapping and validation.md @@ -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