Guest User

Untitled

a guest
Feb 19th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. listFor: function(opts) {
  2. var recordType = opts.recordType ;
  3. var resource = recordType.resourceURL() ; if (!resource) return false ;
  4.  
  5. // TODO: check if the user has given a path to a view.
  6. // if so, call that view (with Method: GET)
  7. var url = resource + "/_temp_view"
  8. var content = {}
  9.  
  10. var context = {
  11. recordType: recordType
  12. }
  13.  
  14. //CHANGED
  15. params = {} ;
  16. var temp = '(doc)';
  17. if (opts.conditions) {
  18. var conditions = this._decamelizeData(opts.conditions) ;
  19. for(var key in conditions) {
  20. temp = '' + temp + ' && (doc.' + key + '==\'' + conditions[key] + '\')';
  21. }
  22. }
  23.  
  24. //CHANGED
  25. content.map = "function(doc) { " +
  26. "if ("+temp+"){ "+
  27. "emit(doc._id, doc)"+
  28. "}}" ;
  29.  
  30. params.requestContext = context ;
  31. params.url = url ;
  32. params.body = content ;
  33. params.onSuccess = this._listSuccess.bind(this) ;
  34. params.onNotModified = this._listNotModified.bind(this) ;
  35. params.onFailure = this._listFailure.bind(this) ;
  36. this.request(resource, this._listForAction, null, params, this._listForMethod) ;
  37. }
Add Comment
Please, Sign In to add comment