Forked from CharlesWinter/count_customer_bookings.go
Created
January 30, 2021 01:09
-
-
Save RyanBalfanz/e6fab94b0a8e8aeb0ff9af5f2d948ef4 to your computer and use it in GitHub Desktop.
Our repository method for counting customer bookings
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 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