function doneQuery(response) {
      _(response.viewpoints).each(function(v) {
        // Determine if the data was paged - if so, create a new selection for the
        // next page of data and add it to the beginning of the queued selections.
        var wasPaged = false;    
      	var newSelection = { viewpoint_id: v.viewpoint_id, get_attributes: false };
      	_(viewpointPagingKeys).each(function (key, category){
    		  if (category in v && v[category].length >= request.limit) {
    		    wasPaged = true;
    		    startKey = key.replace('_last_key', '_start_key');
  		      newSelection['get_' + category] = true;
  		      newSelection[startKey] = v[key];
  		    } else {
  		      newSelection['get_' + category] = false;
  		    }
  		  });
  		  
        wasPaged && selections.unshift(newSelection);
      });
      
      var isLastQuery = (selections.length === 0);
      
      // Send out request for the next page of data, if it exists.
      if (!isLastQuery) sendQuery();
      
      // Invoke the visitor with the returned data for this viewpoint.
      _(response.viewpoints).each(visitor);
           
      // If this was the last page of the query, resolve this method's promise.
      if (isLastQuery) deferred.resolve();
    }
// Successful completion of a single query.
Successful completion of a single query.
Successful completion of a single query .
function doneQuery(response) {
      _(response.viewpoints).each(function(v) {
        var wasPaged = false;    
      	var newSelection = { viewpoint_id: v.viewpoint_id, get_attributes: false };
      	_(viewpointPagingKeys).each(function (key, category){
    		  if (category in v && v[category].length >= request.limit) {
    		    wasPaged = true;
    		    startKey = key.replace('_last_key', '_start_key');
  		      newSelection['get_' + category] = true;
  		      newSelection[startKey] = v[key];
  		    } else {
  		      newSelection['get_' + category] = false;
  		    }
  		  });
        wasPaged && selections.unshift(newSelection);
      });
      var isLastQuery = (selections.length === 0);
      if (!isLastQuery) sendQuery();
      _(response.viewpoints).each(visitor);
      if (isLastQuery) deferred.resolve();
    }
function doneQuery ( response ) { _ ( response . viewpoints ) . each ( function ( v ) { var wasPaged = false ; var newSelection = { viewpoint_id : v . viewpoint_id , get_attributes : false } ; _ ( viewpointPagingKeys ) . each ( function ( key , category ) { if ( category in v && v [ category ] . length >= request . limit ) { wasPaged = true ; startKey = key . replace ( '_last_key' , '_start_key' ) ; newSelection [ 'get_' + category ] = true ; newSelection [ startKey ] = v [ key ] ; } else { newSelection [ 'get_' + category ] = false ; } } ) ; wasPaged && selections . unshift ( newSelection ) ; } ) ; var isLastQuery = ( selections . length === 0 ) ; if ( ! isLastQuery ) sendQuery ( ) ; _ ( response . viewpoints ) . each ( visitor ) ; if ( isLastQuery ) deferred . resolve ( ) ; }
Successful completion of a single query.
Successful completion of a single query .
// Determine if the data was paged - if so, create a new selection for the // next page of data and add it to the beginning of the queued selections. // Send out request for the next page of data, if it exists. // Invoke the visitor with the returned data for this viewpoint. // If this was the last page of the query, resolve this method's promise.