Skip to content

nextQuery always returns a value #1260

@susanlinsfu

Description

@susanlinsfu

I have 42 items which should be returned:

/*
query originally looks like this:
datastore.createQuery('Messages').filter('sender',username).limit(10).autoPaginate(false);
*/

  var query = nextQuery_var_passed_in_from_client;
  getmessages(query,function(err,data){
        if(err){
          console.log('error: ' + err);
        }
    });

});

//callback function
function getrecmessages(query,callback){
    datastore.runQuery(query, function(err, entities, nextQuery, apiResponse){
        if (err) {
            return(callback(err));
        }

        if (nextQuery) {
          console.log('nextQuery = ' + JSON.stringify(nextQuery) );
            if(entities){
                console.log(entities);
            }else{
               console.log('no entities');
         }
        } else {
            // No more results exist.
            console.log('NextQuery IS NULL' );
        }
    });
}

The query first gets the first 10 items, then the next 10, then the next 10, then the remaining 2(42 items). The problem then is when I make the last query to get the last 2 items it returns a nextQuery. As a result it looks as if there is more items even though there are none. I have gone over my code and I can't see anything that is causing this so I am thinking it has something to do with gcloud. I am expecting that when the last query is made no nextQuery should be returned by the datastore. Is this correct?

I am using gcd-rpc emulator and gcloud-node 0.31.0.

Metadata

Metadata

Labels

api: datastoreIssues related to the Datastore API.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions