Chapter 7. Being persistent with a database

 

This chapter covers

  • Configuring Ecto to use a real database
  • Using Ecto to query the database for items
  • Using Ecto to insert items into and delete them from the database

Your Auction application has a public interface where you can query for items, and you know how to bring external package dependencies into the application. In chapter 5, you readied the application for real database use by bringing in Ecto and postgrex (or a different database adapter based on your needs).

You originally set up your Auction application to use a “fake” repo so as not to introduce too much complexity while you built up a small public interface for querying items. It was relatively quick to set up, required no external dependencies, and was fast, but it only allowed you to read a static list of items. For a true data-driven web application, you need the ability to do complex queries as well as insert new items and update existing ones.

In this chapter, you’ll get rid of the fake database and move to a real database. To achieve this, a few prerequisites need to be taken care of:

7.1. A quick intro to Ecto

 
 
 

7.2. Configuring Ecto

 
 
 
 

7.3. Preparing Auction to use the database

 

7.4. Creating, retrieving, and deleting data in the database

 
 

Summary

 
 
 
sitemap

Unable to load book!

The book could not be loaded.

(try again in a couple of minutes)

manning.com homepage
test yourself with a liveTest