5 ms·
I mainly think of contexts as what the "business layer" used to be in the Java world. There's the code that maps to your databases (Ecto structs, like "User" t
by atonse 3y ago
I mainly think of contexts as what the "business layer" used to be in the Java world.
There's the code that maps to your databases (Ecto structs, like "User" that maps to a users table). Then there's the code that explains higher _business_ concepts, (like "register user" - which might insert a user, send an email, etc).
In ruby, for example, a lot of that stuff was just combined in the same active_record classes. So you could say user.register.send_email.
But now you'd do Users.register(user) and Users.send_email().
Just a different name for a pretty standard concept of separating your business level code from your objects as stored in the database.