Schema or not – that is the question

So far, we've talked about schemas as if they were obligatory when one considers implementing the database access with Ecto. Before Ecto 2.0, this was true to some extent, given that many database queries without schemas were more verbose than their schema-powered counterparts, and some database operations were only possible if you chose the schema way of doing things.

Fortunately, those days are over, and you can now perform all operations and queries without a schema in place. As an example, imagine we have a users database table with :username and :email fields. You could insert two new entries on this table by calling the Repo.insert_all/2 function and passing a list of lists, such as [[username: "andre", ...

Get Mastering Elixir now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.