Last active
July 13, 2018 05:59
-
-
Save paragtokopedia/1684c6429849ac3af91604d3e819ef6f to your computer and use it in GitHub Desktop.
Generating Dynamic Queries using DQB
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(queryParams QueryParams) (string) { | |
var dqb DynamicQueryBuilder | |
query = dqb.And( | |
dqb.NewExp("status", "=", queryParams["status"]), | |
dqb.NewExp("phone_number", "=", queryParams["phone_number"]), | |
dqb.NewExp("email", "=", queryParams["email"]), | |
dqb.NewExp("created_at", ">=", queryParams["application_start_date"]), //if empty it will not be added in where clause | |
dqb.NewExp("created_at", "<=", queryParams["application_end_date"]), | |
).Limit(0,10).BindSql("select * from application") | |
return query | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment