Skip to content

Instantly share code, notes, and snippets.

@Ch4s3
Created September 21, 2020 23:19
Show Gist options
  • Save Ch4s3/8100fa09ab947e1def24685130a3aa5c to your computer and use it in GitHub Desktop.
Save Ch4s3/8100fa09ab947e1def24685130a3aa5c to your computer and use it in GitHub Desktop.
select/2 explaination
from(c in City, select: c) # returns the schema as a struct
from(c in City, select: {c.name, c.population}) # returns Tuple of {name, population}
from(c in City, select: [c.name, c.county]) # returns List of [name, county]
from(c in City, select: %{n: c.name, answer: 42}) # returns Map with keys :n, and :answer
from(c in City, select: %{c | alternative_name: c.name}) # returns the schema as a Struct with :alternative_name added
from(c in City, select: %Data{name: c.name}) # returns the selected name in %Data{}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment