-
Notifications
You must be signed in to change notification settings - Fork 923
sqlc for Hexagonal architecture? #944
-
Hey there, awesome library!
Currently, I'm building a service based on hexagonal architecture, and I use sqlc to generate Golang code.
The issue for me is that the querier interface, the parameters, and models are generated with the implementation.
As we want to keep things open, we are wondering if there is a solution to move the querier interface, the parameters, and models outside of the output folder?
Also is there a way to convert the sql.NullString to a *string so the data type could be generic, not specific to SQL?
Beta Was this translation helpful? Give feedback.
All reactions
-
👍 7 -
👎 2
Replies: 2 comments
-
Yeah I would also like to be able to change the output location for each generated file. Below is what I think would be the most logical fit for an existing hexagonal architecture. Also be able to specify different package for each.
models.go
-> internal/domain
querier.go
-> internal/core/ports/services.go
? -> internal/core/ports/repositories.go
query.sql.go
-> internal/services/usersrv/service.go
db.go
-> maybe the Queries struct and Methods can be split into internal/repositories/postgres/user.go (as it is actual implementation)
Beta Was this translation helpful? Give feedback.
All reactions
-
I suggest you consider the sqlc gen code as an adapter only and do the mapping with your domain structs instead of directly use the sqlc models as your domain
Beta Was this translation helpful? Give feedback.