Skip to content

Instantly share code, notes, and snippets.

@2color
Created February 5, 2020 14:10
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save 2color/660ca7a9a0742ea1a0136c0ae437b547 to your computer and use it in GitHub Desktop.

ORM Patterns

In practice there are two common ORM patterns:

  • ActiveRecord: uses the model class to handle both business logic and database access.
  • DataMapper: a more complex approach which separates the in-memory objects from the database. Uses two class types:
    • Mapper: handles database access and mapping entities
    • Entities: in-memory representation with business logic

Some ORMs, like TypeORM support both patterns. Others like Sequelize support only ActiveRecord.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment