Hacker News new | ask | show | jobs
by lilactown 3375 days ago
It's confusing because it's using a library called Ecto, which provides it's own DSL for describing schemas and queries.

NOTE: I haven never used Ecto, but I have used Elixir for a few hobby projects.

1. `embeds_many` is a function name, described here: https://hexdocs.pm/ecto/Ecto.Schema.html#embeds_many/3

2. Anything that begins with a colon is an Atom in Elixir, including :string, :map, :changes, :field, and :value. These atoms are used by Ecto at runtime to identify certain things. `:changes` is a unique name given to the embedded schema, `:field` and `:value` are field names on that schema, and :string and :map are informing Ecto of how to treat certain values.

3. `Change` is the name of a Module which describes the Schema we are embedding

4. `primary_key: false` is a configuration option

5. Everything after `do...` is describing what the embedded schema would look like. So it has a `:field` field that is of type string, and a `:value` field that is of type map.

Hopefully that makes some sense... I'm not totally clear on it either (having not used Ecto before) but that's what I'm grokking.

1 comments

Thanks