Ecto

Ecto




What's in this preview?

We want you to get the feel for typical Groxio content and the reasons we provide each type of content. Each Groxio module comes in four scheduled releases consisting of the central PDF, videos, and resource links. Later releases have projects as well. You can see part of the first release here.

An explicit, repo-based database mapping and query service for Elixir



Buy Course Today!



Preview PDF!



Preview Epub!




Release Schedule: 2021-06-01 through 2021-08-09

Version: Aug 9, 2021


Just $70.00, A La Carte
(other options available)




Programmer Passport Ecto






Why a book?

The scientific teaching method we follow is the Dreyfus learning model. Books provide the metaphors experts need to build context, step-by-step instructions for beginners, and the exercises that intermediates need to learn.

Itinerary


Design and Setup

Queries

Relationships

Updates & Advanced Topics

Why an itinerary?

The itinerary is a virtual guide. This optional list describes the highlights of each release to maximize your learning time.

Description

Ecto is the de facto persistence layer for Elixir. It works best with relational databases, but some extensions are emerging for other data base abstractions too. The database layer lets you fetch database data so you can deal with it in your application or create data in your appliction and save it to the database in a reliable way.


The primary features are an API that features a clean separation between functions that work with data, and functions that interact directly with the database system. Ecto also features changesets which let users deal with user input in a practical way that enables both effective user interfaces and database integrity.

History

Shortly after the creation of Elixir in 2013, José Valim worked with Eric Meadows-Jönsson on Ecto over the Google Summer of Code. Github shows those two are the top contributors to Ecto, but the project has seen contributions from more than 100 developers spanning the life of the project.




Course Objectives

Groxio courses focus on concepts rather than features. Since the Elixir community has plenty of support for Ecto features and mappings, we’ll spend more of our time working through design concepts. We’ll weave in the concepts you’ve seen in other Groxio courses like the CRC (construct - reduce - convert) pattern and the software layering system created in Designing Elixir Systems with OTP.


When you’re done, you’ll be able to:

  1. Create an Ecto project with and without Phoenix.

  2. Construct layered Ecto models, and understand which layers go where.

  3. Build composable query systems that offer flexibility to a core query layer.

  4. Learn basic Ecto mappings such as belongs-to and has-one.

  5. Work with relationships using explicit loading and aggregations.

  6. Extend the Ecto ecosystem by dropping into SQL

Videos

Public & Private




Why videos?

Groxio language modules have two kinds of videos. Our overview videos set the history and context of a language, or wrap up the work we've done, and are free to support language ecosystems. Our coding instruction videos, mostly starting with the second release, are paid content, and each one offers a live coding project.

Every learning level benefits from pair programming. Our videos are professional, but do not scrub away every tiny mistake. That way, you can see how experienced programmers deal with errors and changes in code organization.

Intro. Design for Ecto

Ecto is the database library for Elixir. It has several interesting features. One of the most important is the design decision to separate database access through a repo from the pure functional features of working with data. This video walks through the layers of an Elixir system, and where your Ecto code fits.

Video

1. Ecto Without Phoenix

Ecto is the database layer behind Elixir. Most Elixir developers learn to use it through the Phoenix framework, but you don't have to. This video walks through the steps to creating an Ecto project, plugging in the supervisor, and dialing in your configuration using an idiomatic Elixir mix project.
Subscriber content

Video

2. Ecto Schemas

Ecto schemas define a mapping between a database table and an Elixir data structure. None of the database access actually happens in the schema, though. This video will walk you through the schema itself, it's purpose, and how to fit your schemas into a well-designed Elixir application.
Subscriber content

3. Ecto Query Overview

Ecto is a persistence library that separates the concepts of query *building* from query *execution*. This video walks you through the critical separation of concerns, and how using CRC within Ecto can provide clean composition in the core with powerful query execution in the boundary.

Video

4. Using Ecto Select to Shape Query Results

Using Ecto, you can often transform query results within the query without resorting to raw Elixir tools. The `select` key does the work by specifying types, fields, and even templates to precisely define the shape of the data you want Ecto to return.
Subscriber content

Video

5. Ecto Query Dimensions

Ecto queries are powerful, but sometimes the different dimensions to the data are confusing. This video talks through the tools you have to return bigger or smaller result sets whether you are restricting data to a limited set of rows, filtering results, restricting the columns, or expanding the returned tables.
Subscriber content

Video

6. Ecto Associations

Ecto uses associations to tie two schemas together. In this video, Bruce walks you through how to build a new migration, schema, and the association between the two. Then, he'll migrate, create a create a new changeset, and then insert new data into the database.
Subscriber content

Video

7. Ecto Join and Preload

Ecto queries use joins and preloads to span tables. This video first covers preloads, which fetch related data on demand for a given association. Then, it examines joins, which give Ecto uses to combine two physical tables into one logical one.
Subscriber content

Video

8. Ecto Bindings

Ecto uses bindings within a query to connect query variables to specific rows in Ecto tables. Through bindings, you can express complex concepts as you specify joins, filters, groupings, and the like. With the `as` clause, you can also refer to bindings across disparate composable functions.
Subscriber content

9. Ecto Reflection

Elixir's Ecto has a library that supports reflection. One of the nice things about a database mapping library is that you can use code to explore relevant details about a given schema. Ecto's reflection provides all of the details necessary to traverse and build custom code for any schema relationship.

Video

10. Database Integrity Explained

Ecto has good tools for database integrity, but why should you need them? Database consistency involves more than just building changesets. Certain database frameworks allow concurrency bugs to creep in. Ecto allows a good integration for transactions and unique index, and this video explains why you need them.
Subscriber content

Video

11. Ecto Transactions and Multis

Ecto's transactions and multis prevent concurrency bugs with several different mechanisms. At the base level, you can enable transactions that group together operations into an atomic update. At a higher level, Ecto multis group together several different functions that perform database updates.
Subscriber content

Community Resources

Cool quick trips for Ecto




Why resource links?

Each new chapter has a set of links, separated into three categories. The categories reflect different competency levels and resources that match that stage of learning, for each Groxio release.

Learn It

These resources will get you on the path to learning with background information, tooling and exercises.

Do It

You decide how deep to go. These resources are exercises and projects to cement your learning.

Grok It

These resources will help you put your new knowledge into context so you'll be better at your everyday job.

Projects

Longer Excursions (chapters 3 and 4)






Why projects?

The Dreyfus model is originally instruction for pilots. A typical pilot course is based on reading material to understand context, and then flying a plane. Our videos and PDFs are important, but in the end, programmers need to program in order to learn. Our projects offer different levels of assistance, from "give me the answer" to "make this test pass".