Created
January 22, 2021 15:59
-
-
Save CharlesWinter/cfa269ae905b30db0ebf39b803eb347b to your computer and use it in GitHub Desktop.
Our repository method for counting customer bookings
This file contains 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
ackage bookings | |
type Repository struct { | |
// in reality, this client will likely be something we generate from a | |
// schema, or implement ourselves if needs be. Its not discussed here for | |
// conciseness | |
client bookingsServiceClient | |
} | |
type booking struct { | |
ID uint `json:"id"` | |
} | |
func (r *Repository) CountCustomerBookings(customerID uint) (uint, error) { | |
// we make a request to the bookings service here. This is done in pseudocode | |
// so as not to get bogged down in the details. | |
bookings, err := r.client.GetCustomerBookings(customerID) | |
var numBookings uint = len(bookings) | |
return numBookings, err | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@CharlesWinter, you have a small typo on line 1 ;)