Skip to content

Instantly share code, notes, and snippets.

@ccapndave
Created March 25, 2019 16:33
Show Gist options
  • Save ccapndave/d00673a455b0aa50592dcaf2de2eacb9 to your computer and use it in GitHub Desktop.
Save ccapndave/d00673a455b0aa50592dcaf2de2eacb9 to your computer and use it in GitHub Desktop.

Important! Please use this feature only when strictly necessary, otherwise it is very easy to end-up with large schemas with dozens of different associations polluting your schema and affecting your application performance. For instance, if you are using associations only for different querying purposes, then it is preferable to build and compose queries, rather than defining multiple associations:

posts
|> Ecto.assoc(:comments)
|> Comment.deleted()

Or when preloading:

from posts, preload: [comments: ^Comment.deleted()]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment