Skip to content

Instantly share code, notes, and snippets.

@raorao
Last active August 29, 2015 14:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raorao/f0c6b0f92cd85b9ea37f to your computer and use it in GitHub Desktop.
Save raorao/f0c6b0f92cd85b9ea37f to your computer and use it in GitHub Desktop.
Query = {}
Query.new = function() {
var queryAttributes = {
filters: [],
beginDate: null,
endDate: null,
attribute: null
}
var queryObj = {
where: function(filter) {
queryAttributes.filters.push(filter)
return queryObj;
},
between: function(begin,end) {
queryAttributes.beginDate = begin
queryAttributes.endDate = end
return queryObj;
},
for: function(attributeName) {
queryAttributes.attribute = attributeName
return queryObj;
},
toMapping: function() {
return queryAttributes;
}
}
return queryObj;
}
var dailyWidgetQuery = Query.new().for('widgets').where({name: 'glen'}).where({type: 'lame'}).between(1,6)
dailyWidgetQuery.toMapping()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment