DEV Community

Discussion on: Implementing SOLID and the onion architecture in Node.js with TypeScript and InversifyJS

Collapse
 
remojansen profile image
Remo H. Jansen

We use the data mapper because we don't want to "pollute" our entire application with data-access concerns. The TypeORM entities are data-access concerns because they are a 1-to-1 map to the database tables and contain database-related metadata added via decorators. We use the domain entities instead in the entire system but the data access layer (DAL) cannot use domain entities to persist them (via TypeORM). So the data mapper job is to translate in and out of the DAL from domain-entity-to-orm-entity (in) and from orm-entity-to-domain-entity (out).