Last active
September 10, 2021 09:50
-
-
Save percybolmer/d34695a2c493f1beb49fd7ad066e594d to your computer and use it in GitHub Desktop.
graphql
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
// GetJobs returns all jobs for a certain Employee | |
func (imr *InMemoryRepository) GetJobs(employeeID, companyName string) ([]Job, error) { | |
if jobs, ok := imr.jobs[employeeID]; ok { | |
filtered := make([]Job, 0) | |
// Filter out companyName | |
for _, job := range jobs { | |
// If Company Is Empty accept it, If Company matches filter accept it | |
if (job.Company == companyName) || companyName == "" { | |
filtered = append(filtered, job) | |
} | |
} | |
return filtered, nil | |
} | |
return nil, errors.New("no such employee exist") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment