Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always MORE_RESULTS_AFTER_LIMIT returned #1318

Closed
susanlinsfu opened this issue May 14, 2016 · 3 comments
Closed

Always MORE_RESULTS_AFTER_LIMIT returned #1318

susanlinsfu opened this issue May 14, 2016 · 3 comments
Assignees
Labels
api: datastore Issues related to the Datastore API.

Comments

@susanlinsfu
Copy link

susanlinsfu commented May 14, 2016

I of course might be missing something, but I have 10 entities in my KIND. I run the following code:

var NUM_RESULTS_PER_PAGE = 5;

app.get('/getusers', function(req, res) {
  var query = datastore.createQuery('users')
    .limit(NUM_RESULTS_PER_PAGE);

  if (req.query.nextPageCursor) {
    query.start(req.query.nextPageCursor);
  }

  datastore.runQuery(query, function(err, entities, info) {
    if (err) {
      // Error handling omitted...
      return;
    }

    // Respond to the front end with the contacts and the cursoring token
    // from the query we just ran.
    var frontEndResponse = {
      contacts: entities
    };

    // Check if  more results may exist.
    if (info.moreResults !== gcloud.datastore.NO_MORE_RESULTS) {
      frontEndResponse.nextPageCursor = info.endCursor;
    }

    res.render('contacts', frontEndResponse);
  });
});

I run the code, it gets the first 5 entities (1-5) and it returns MORE_RESULTS_AFTER_LIMIT. I then take the nextPageCursor and query again, it now gets the next 5 entities (6-10) and it returns MORE_RESULTS_AFTER_LIMIT. There are no more entities though, and I take the cursor from this response it now returns no entities since there are no more, but it still returns MORE_RESULTS_AFTER_LIMIT, but there are no more? I would expect to receive NO_MORE_RESULTS?

@stephenplusplus stephenplusplus added the api: datastore Issues related to the Datastore API. label May 16, 2016
@stephenplusplus
Copy link
Contributor

Is this using the emulator?

@susanlinsfu
Copy link
Author

Using gcd.sh

@stephenplusplus
Copy link
Contributor

This is because the emulator issue is still unresolved: (related: #1237 (comment), #1260 (comment))

@pcostell will update you when it's resolved (#1260 (comment)):

Right now, the next_query is still returned even though there are no more results. I'll try to make sure to explicitly send an update when the emulator has better more_results support.

Sorry for the confusion!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: datastore Issues related to the Datastore API.
Projects
None yet
Development

No branches or pull requests

2 participants