Generate XXX schema
phx.gen.schema MODULE_NAME RESOURCEs attribute:value1 attributeN:valueN
Create file in lib/APPNAME/RESOURCEs.ex which define schema
Migrate
mix phx.migrate
- Run file in priv/repo/migrations
Ecto schema
Mapping Elixir values <---> external data source and mapping relationship one schema <---> other schemas
Ecto changesets
Changesets defines a pipeline of transformations.
Transformations: - Casting - Validating - Filtering
External data ---- CHANGESETS ----> ready data.
Persistent
- Insert
Repo.insert(%Resource{key1:value1, ...})
- Select
Repo.one(from s in Student, where: ilike(s.email, "%u%"), select: s.email)
Repo.all(from s in Student, select: %{s.id => s.email})
Context
- Grouping feature, make them independent, encapsulate concepts
- Generate a site with
mix phx.gen.html CONTEXT MODULENAME Resources field1:type1 field2:type2 ...