Skip to main content
added 83 characters in body
Source Link
Omeri
  • 111
  • 2

Very interesting technologies you are using. I have debated the same thing in a different implementation with Spring Boot services. My choice was to separate the database entities from the models being returned to the client. It seems like there needs to be some intentional layer of separation there since if someone inadvertently added fields to the database and the entities it could accidentally break a service contract. In Java there are helpers thethat AutoMap between entities and data transfer objects which might help but like you I have a factory that builds these mappings manually. I would be interested to see what others have to say here as well.

A quick Google lookup shows that there might be automapping options for Go as well, so might want to give that a try.

For example: https://pkg.go.dev/github.com/PeteProgrammer/go-automapper

Final point I wanted to make is that from experience I have noticed that it is easy to get carried away and expose an API for each model when in fact many models are often bundled as part of a parent model and might not deserve their own endpoint.

Very interesting technologies you are using. I have debated the same thing in a different implementation with Spring Boot services. My choice was to separate the database entities from the models being returned to the client. It seems like there needs to be some intentional layer of separation there since if someone inadvertently added fields to the database and the entities it could accidentally break a service contract. In Java there are helpers the AutoMap between entities and data transfer objects which might help but like you I have a factory that builds these mappings manually. I would be interested to see what others have to say here as well.

A quick lookup shows that there might be automapping options for Go as well, so might want to give that a try.

Final point I wanted to make is that from experience I have noticed that it is easy to get carried away and expose an API for each model when in fact many models are often bundled as part of a parent model and might not deserve their own endpoint.

Very interesting technologies you are using. I have debated the same thing in a different implementation with Spring Boot services. My choice was to separate the database entities from the models being returned to the client. It seems like there needs to be some intentional layer of separation there since if someone inadvertently added fields to the database and the entities it could accidentally break a service contract. In Java there are helpers that AutoMap between entities and data transfer objects which might help but like you I have a factory that builds these mappings manually. I would be interested to see what others have to say here as well.

A quick Google lookup shows that there might be automapping options for Go as well, so might want to give that a try.

For example: https://pkg.go.dev/github.com/PeteProgrammer/go-automapper

Final point I wanted to make is that from experience I have noticed that it is easy to get carried away and expose an API for each model when in fact many models are often bundled as part of a parent model and might not deserve their own endpoint.

Source Link
Omeri
  • 111
  • 2

Very interesting technologies you are using. I have debated the same thing in a different implementation with Spring Boot services. My choice was to separate the database entities from the models being returned to the client. It seems like there needs to be some intentional layer of separation there since if someone inadvertently added fields to the database and the entities it could accidentally break a service contract. In Java there are helpers the AutoMap between entities and data transfer objects which might help but like you I have a factory that builds these mappings manually. I would be interested to see what others have to say here as well.

A quick lookup shows that there might be automapping options for Go as well, so might want to give that a try.

Final point I wanted to make is that from experience I have noticed that it is easy to get carried away and expose an API for each model when in fact many models are often bundled as part of a parent model and might not deserve their own endpoint.