Skip to content

Instantly share code, notes, and snippets.

@paragtokopedia
Last active July 12, 2018 05:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paragtokopedia/c424bc7151b5042df21b1c798cf82ccc to your computer and use it in GitHub Desktop.
Save paragtokopedia/c424bc7151b5042df21b1c798cf82ccc to your computer and use it in GitHub Desktop.
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