Entities and Models, DTOs oh my?
Going through some courses I noticed that some time they use model and entities and other times they are just using models.
What is the difference here?
8 Replies
entities usually refers to things that are in a DB, models is a Bad Word (TM) that stands for everyThing and, while we're at it: DTO (Data Transfer Object) usually means a specialized Type for a (couple of) specific use cases (that don't require all the info of a specific model or infos from multiples...)
basically, i'd recommend you don't worry about the wording here.
people tend to be more imprecise than you expect.
gotcha,
so just to be clear here.
Entities
- reference the data that is in the database.
DTOs
- specialized types that are used. that are not used to reference db entities
^ would these be correct statements?broadly, i'd say.
You will also so
DAO
(Data Access Object) instead of Entities
sometimes.
Model is quite vague, but if someone speaks of DTO and DAO in the same sentence, they're is a good chance Model refers to what comes in from the API.Yeah looking at some documentation and videos it looks like using entities to map to the tables that we are creating in the database while we can use DTO‘s and DAO‘s as contracts that we want to use from an inbound and outbound perspective.
would this be a better summary? High-level
AdmSnyder#8493
basically, i'd recommend you don't worry about the wording here.
Quoted by
<@!163876962710847488> from #Entities and Models, DTOs oh my? (click here)
React with ❌ to remove this embed.
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
DTOs are commonly the things you return to frontend through your controllers. so you and your frontend colleague will usually have an agreement on what to work with, this will be in the form of dtos.