Created
March 30, 2011 07:29
-
-
Save alexbosworth/894008 to your computer and use it in GitHub Desktop.
This file contains 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
Sdb.prototype.getQueryString = function(query) { | |
if (!query.domain) throw new Error('no domain specified'); | |
if (!query.fields || !query.fields.length) query.fields = '*'; | |
var str = query.fields.join() + ' from ' + query.domain; | |
if (query.selectors && query.selectors.length) | |
str+= ' where ' + query.selectors.join(' intersection '); | |
if (query.order) str+= ' order by ' + query.order; | |
if (query.limit) str+= ' limit ' + query.limit; | |
return str; | |
} | |
Sdb.prototype.select = function(query, token) { | |
if (!query) throw new Error('no query specified'); | |
// can pass a query object with <fields [], domain str, selectors [], limit int, order str> | |
if (typeof(query) != 'string') query = this.getQueryString(query); | |
this.params.SelectExpression = 'select ' + query; | |
if (token) this.params.NextToken = token; | |
return this.request('Select'); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment