Last active
January 31, 2019 16:06
-
-
Save marinho10/9730c4b93fed0e52a2262233f08b31f3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def upsert_user_projects(user, project_ids) when is_list(project_ids) do | |
projects = | |
Project | |
|> where([project], project.id in ^project_ids) | |
|> Repo.all() | |
with {:ok, _struct} <- | |
user | |
|> User.changeset_update_projects(projects) | |
|> Repo.update() do | |
{:ok, Accounts.get_user(user.id)} | |
else | |
error -> | |
error | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment