Active Record
About this...
An `Active Record` is a model that stores an in-memory representation of a database row or document.
You know Sequelize, TypeORM, and Mongoose?
Those are all ORMs. When you return an instance of a row (or document), being able to make changes to the database row (that the instance references) is a popular usage of the Active Record pattern.
The Active Record pattern was initially documented by Martin Fowler
// Updating the 'name' column of a user using Sequelize.
const user = await User.find({ where: { user_id: 1 }});
await user.update({ name: 'Don Draper' });
Using instances of row objects returned from the ORM technology of our choice, we can Create, Read, Update and Delete instances of pretty much anything inside of the database.
Pretty cool!
We're just getting started 🔥 Interested in how to write professional JavaScript and TypeScript? Join 8000+ other developers learning about Domain-Driven Design and Enterprise Node.js. I won't spam ya. 🖖 Unsubscribe anytime.

0 Comments
Be the first to leave a comment