Created
August 26, 2008 21:48
-
-
Save nickjs/7360 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
listFor: function(opts) { | |
var recordType = opts.recordType ; | |
var resource = recordType.resourceURL() ; if (!resource) return false ; | |
// TODO: check if the user has given a path to a view. | |
// if so, call that view (with Method: GET) | |
var url = resource + "/_temp_view" | |
var content = {} | |
var context = { | |
recordType: recordType | |
} | |
//CHANGED | |
params = {} ; | |
var temp = '(doc)'; | |
if (opts.conditions) { | |
var conditions = this._decamelizeData(opts.conditions) ; | |
for(var key in conditions) { | |
temp = '' + temp + ' && (doc.' + key + '==\'' + conditions[key] + '\')'; | |
} | |
} | |
//CHANGED | |
content.map = "function(doc) { " + | |
"if ("+temp+"){ "+ | |
"emit(doc._id, doc)"+ | |
"}}" ; | |
params.requestContext = context ; | |
params.url = url ; | |
params.body = content ; | |
params.onSuccess = this._listSuccess.bind(this) ; | |
params.onNotModified = this._listNotModified.bind(this) ; | |
params.onFailure = this._listFailure.bind(this) ; | |
this.request(resource, this._listForAction, null, params, this._listForMethod) ; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment