Skip to content

Instantly share code, notes, and snippets.

@marick
Last active September 1, 2016 20:44
Show Gist options
  • Select an option

  • Save marick/5e0e589701e70da9a0074254af8bee15 to your computer and use it in GitHub Desktop.

Select an option

Save marick/5e0e589701e70da9a0074254af8bee15 to your computer and use it in GitHub Desktop.
# Elixir Ecto. Make a new reservation for a set of (already existing) animals and procedures
def insert_new!(reservation_fields, animals, procedures) do
uses = for a <- animals, p <- procedures, do: %OldUse{animal: a, procedure: p}
only_group = %OldGroup{uses: uses}
reservation = %{reservation_fields | groups: [only_group]}
Eecrit.OldRepo.insert!(reservation)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment