Hi,
We are developing our application using typeorm(MSSQL database) and angular 5 as frontend framework. When i checked the sample programs , everything has just a controller method where entities are directly passed as API response. If we look at old applications, most of them have a domain(like our entities), services, controllers and DTO's(this will be send as API response). How can we acheive such DTO object in typeorm. Since we dont like to expose database as such to front end. Is there any library to do so? Or you are suggesting to go ahead with controller and entity framework? Which one would the best practice ? What kind of architecture will be best suited for typeorm
[X ] question
Database system/driver:
[X ] mssql
TypeORM version:
[ ] latest
[ ] @next
[ ] 0.x.x (or put your version here)
Samples are just simple samples written in a short and understandable way.
So, your question is not related to typeorm anyhow, typeorm is architecture agnostic, choose whatever architecture you prefer or your app requires.
If you ask me I usually don't do separate DTOs since data I have in my models in db are direct representation of what I need on the frontend and I think separate layer brings complexity and redundancy in most cases. If you want to control what you are going to return to the frontend, you simply do not select / remove not needed properties before sending to the frontend. I create separate models for the frontend only when its completely different data rather then what I have in the database.
Most helpful comment
Samples are just simple samples written in a short and understandable way.
So, your question is not related to typeorm anyhow, typeorm is architecture agnostic, choose whatever architecture you prefer or your app requires.
If you ask me I usually don't do separate DTOs since data I have in my models in db are direct representation of what I need on the frontend and I think separate layer brings complexity and redundancy in most cases. If you want to control what you are going to return to the frontend, you simply do not select / remove not needed properties before sending to the frontend. I create separate models for the frontend only when its completely different data rather then what I have in the database.