Understanding the role of contexts

We talked a little bit about the sorts of issues that would lead us to want to control how our code is used and written since we don't want maintenance to become a giant hassle for us in the future. Therefore, let's instead simplify our lives by providing a single interface for related schemas and database operations.

Contexts fill that void by providing that unified interface, typically providing human-readable functions that allow the fetching, inserting, updating, and deleting of data. It can also do other database-specific operations that may be difficult to figure out ownership of (for example, should adding a new option to a poll live on the Poll or live on the schema? The correct answer is: neither!). ...

Get Phoenix Web Development 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.