Published Sep 3, 2019

SE-Radio Episode 349: Gary Rennie on Phoenix

Gary Rennie delves into the Phoenix framework, highlighting its powerful ecosystem, real-time capabilities, and optimization strategies, while offering valuable insights on the Ecto database tool for efficient web app development and deployment.
Episode Highlights
Software Engineering Radio - the podcast for professional software developers logo

Popular Clips

Episode Highlights

  • Ecto Basics

    Ecto, a crucial component of Phoenix, serves as an abstraction layer for database interactions, allowing developers to define schemas and queries without writing raw SQL. explains that Ecto is not an ORM due to Elixir's lack of objects, but it provides a queryable struct to build transformations using its API 1. This struct is then executed against the database using the repository pattern, which supports multiple repositories for different data sources, including PostgreSQL, MySQL, and even MongoDB 2.

    You define schemas for Ecto and you can define queries against those schemas.

    ---

    Rennie highlights the flexibility of Ecto, noting its ability to use raw SQL fragments for unsupported functions and its dual query syntax inspired by C#'s LINQ 2.

       

    Transaction Handling

    Ecto's transaction handling capabilities are robust, offering explicit control over database operations through its multi feature. describes how Ecto allows for transactions that span multiple repositories and functions, ensuring that all operations succeed or fail together 3. This is particularly useful for complex operations, such as user registration processes that involve multiple steps like sending an SMS 3.

    If the SMS fails, then we don't want the user to be inserted.

    ---

    Additionally, Rennie explains that Ecto's transaction handling is explicit, requiring developers to specify which repository to use, thus avoiding any implicit database interactions 4.

Related Episodes