Skip to content

Instantly share code, notes, and snippets.

@nobleach
Created April 29, 2014 13:24
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 nobleach/11400269 to your computer and use it in GitHub Desktop.
Save nobleach/11400269 to your computer and use it in GitHub Desktop.
buildQuery: function() {
var query = [];
var name = this.username.value;
var startDate = this.startDate.value;
var endDate = this.endDate.value;
if(name) {
query.push("username LIKE '%"+name+"%'");
}
if(startDate) {
query.push("time > '"+startDate+"'");
}
if(endDate) {
query.push("time < '"+endDate+"'");
}
if(query.length > 1) {
return query.join(' AND ');
} else {
return query.join('');
}
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment