> For the complete documentation index, see [llms.txt](https://montrealelixir.gitbook.io/playbook/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://montrealelixir.gitbook.io/playbook/trails/ecto.md).

# Ecto

## Getting started

* Get motivated: [Leveling Up With Ecto](https://www.youtube.com/watch?v=QE7bpqpDoKo)
* Start with "Programming Phoenix". Part 1 contains chapters specifically related to Ecto which will provide a foundation.
* Read the API documentation. Focus on these areas:
  * [Ecto Overview](https://hexdocs.pm/ecto/2.0.0-beta.2/Ecto.html)
  * [Repo](https://hexdocs.pm/ecto/2.0.0-beta.2/Ecto.Repo.html)
  * [Schema](https://hexdocs.pm/ecto/2.0.0-beta.2/Ecto.Schema.html)
  * [Changesets](https://hexdocs.pm/ecto/2.0.0-beta.2/Ecto.Changeset.html)
  * [Query](https://hexdocs.pm/ecto/2.0.0-beta.2/Ecto.Query.html) and [Query.API](https://hexdocs.pm/ecto/2.0.0-beta.2/Ecto.Query.API.html)
* [What's new in Ecto 2.0](http://pages.plataformatec.com.br/ebook-whats-new-in-ecto-2-0)

## Additional References to help out round your understanding:

* [Composable Queries with Ecto](https://blog.drewolson.org/composable-queries-ecto/)
* [Working with Ecto associations and embeds](http://blog.plataformatec.com.br/2015/08/working-with-ecto-associations-and-embeds/)
* [The Ecto Query Library - Lew Parker](http://www.glydergun.com/the-ecto-query-library/) ([GitHub Repo](https://github.com/parkerl/ecto_query_librar://github.com/parkerl/ecto_query_library))
* [Nicholas' Bookmarks](https://pinboard.in/u:nicholasjhenry/t:ecto/)

## Talks

* [Composable Queries with Ecto](http://confreaks.tv/videos/elixirconf2015-composable-queries-with-ecto)
* [Ecto](http://confreaks.tv/videos/elixirconfeu2015-ecto)

## "Patterns"

Ecto, as a database wrapper, is significantly different to ORM such as Rails' ActiveRecord. Dealing with certain data structures are not quite "out-of-the box". Here's a few patterns to deal with these:

* [Many to many and upserts](http://blog.plataformatec.com.br/2016/12/many-to-many-and-upserts/)
* TODO: Add another Many to many
* [Modeling Polymorphic Associations in a Relational Database](https://hashrocket.com/blog/posts/modeling-polymorphic-associations-in-a-relational-database)
* [Ecto Docs Polymorphic Associations](https://hexdocs.pm/ecto/Ecto.Schema.html#belongs_to/3-polymorphic-associations)

## Asking for help

* [Google Groups](https://groups.google.com/forum/#!forum/elixir-ecto)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://montrealelixir.gitbook.io/playbook/trails/ecto.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
