DEV Community

Discussion on: Postgres module for NestJS 8.x/9.x/10.x framework 😻

Collapse
 
ecyrbe profile image
ecyrbe • Edited

As a reminder for everyone reading this code. Do not do it like that.

Separate your DTO from your data base models (Entity) with an adapter (Repository) interface.

Entities are for abstracting your database away. DTO is for abstracting your business logic away.

Your services should bridge DTO and Entities where you can add business logic. Your Repository abstract your Entities from your database to allow you to use another library / database without rewriting all your business logic.

Collapse
 
tony133 profile image
Antonio Tripodi

Hi ecyrbe, i wrote it like this just to show how it works then to make it understand even by those coming from orm type as typeorm, however I agree with what you said too I use the pattern repository. I leave the freedom to anyone to make their own choices as it should be. 👍