Created
January 22, 2021 15:13
-
-
Save CharlesWinter/a92701826c730411f184e33e7ed1a9bf to your computer and use it in GitHub Desktop.
The repositories/customers/repository.go File
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package customers | |
| type Repository struct { | |
| // This is where whatever the repository will use to access the DB will live | |
| // as an unexported field. Nothing groundbreaking here. | |
| somethingToAccessTheDB interface{} | |
| } | |
| // NewRepository will return a new instance of the customers.Repository. I've | |
| // not outfitted it with actual DB connection logic so as to keep this article | |
| // concise. The one takeaway here is that the DB accessor/provided should | |
| // itself be injected, but that's out of the scope of this article. | |
| func NewRepository(somethingToAccessTheDB interface{}) *Repository { | |
| return &Repository{ | |
| somethingToAccessTheDB, | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment