Last active
July 12, 2018 05:49
-
-
Save paragtokopedia/c424bc7151b5042df21b1c798cf82ccc to your computer and use it in GitHub Desktop.
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
func GenerateQuery(params map[string]string) string { | |
where := "where 1=1" | |
if status, ok := params["status"]; ok { | |
where += " AND status='" + status + "'" | |
} | |
if phone_number, ok := params["phone_number"]; ok { | |
where += " AND phone_number='" + phone_number + "'" | |
} | |
if email, ok := params["email"]; ok { | |
where += " AND email='" + email + "'" | |
} | |
if application_start_date, ok := params["application_start_date"]; ok { | |
where += " AND created_at >='" + application_start_date + "'" | |
} | |
if application_end_date, ok := params["application_end_date"]; ok { | |
where += " AND created_at <='" + application_start_date + "'" | |
} | |
return "select * from applications " + where +" LIMIT 10 OFFSET 0" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment