{"action":"created","issue":{"url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-node/issues/1260","repository_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-node","labels_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-node/issues/1260/labels{/name}","comments_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-node/issues/1260/comments","events_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-node/issues/1260/events","html_url":"https://github.com/GoogleCloudPlatform/gcloud-node/issues/1260","id":150714297,"number":1260,"title":"nextQuery always returns a value","user":{"login":"susanlinsfu","id":15883441,"avatar_url":"https://avatars.githubusercontent.com/u/15883441?v=3","gravatar_id":"","url":"https://api.github.com/users/susanlinsfu","html_url":"https://github.com/susanlinsfu","followers_url":"https://api.github.com/users/susanlinsfu/followers","following_url":"https://api.github.com/users/susanlinsfu/following{/other_user}","gists_url":"https://api.github.com/users/susanlinsfu/gists{/gist_id}","starred_url":"https://api.github.com/users/susanlinsfu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/susanlinsfu/subscriptions","organizations_url":"https://api.github.com/users/susanlinsfu/orgs","repos_url":"https://api.github.com/users/susanlinsfu/repos","events_url":"https://api.github.com/users/susanlinsfu/events{/privacy}","received_events_url":"https://api.github.com/users/susanlinsfu/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-node/labels/datastore","name":"datastore","color":"0052cc"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":9,"created_at":"2016-04-24T23:48:33Z","updated_at":"2016-04-26T22:09:43Z","closed_at":null,"body":"I have 42 items which should be returned:\r\n\r\n```\r\n/*\r\nquery originally looks like this:\r\ndatastore.createQuery('Messages').filter('sender',username).limit(10).autoPaginate(false);\r\n*/\r\n\r\n  var query = nextQuery_var_passed_in_from_client;\r\n  getmessages(query,function(err,data){\r\n        if(err){\r\n          console.log('error: ' + err);\r\n        }\r\n    });\r\n\r\n});\r\n\r\n//callback function\r\nfunction getrecmessages(query,callback){\r\n    datastore.runQuery(query, function(err, entities, nextQuery, apiResponse){\r\n        if (err) {\r\n            return(callback(err));\r\n        }\r\n\r\n        if (nextQuery) {\r\n          console.log('nextQuery = ' + JSON.stringify(nextQuery) );\r\n            if(entities){\r\n                console.log(entities);\r\n            }else{\r\n               console.log('no entities');\r\n\t     }\r\n        } else {\r\n            // No more results exist.\r\n            console.log('NextQuery IS NULL' );\r\n        }\r\n    });\r\n}\r\n```\r\n\r\nThe 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?\r\n\r\nI am using gcd-rpc emulator and gcloud-node 0.31.0. "},"comment":{"url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-node/issues/comments/214903121","html_url":"https://github.com/GoogleCloudPlatform/gcloud-node/issues/1260#issuecomment-214903121","issue_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-node/issues/1260","id":214903121,"user":{"login":"susanlinsfu","id":15883441,"avatar_url":"https://avatars.githubusercontent.com/u/15883441?v=3","gravatar_id":"","url":"https://api.github.com/users/susanlinsfu","html_url":"https://github.com/susanlinsfu","followers_url":"https://api.github.com/users/susanlinsfu/followers","following_url":"https://api.github.com/users/susanlinsfu/following{/other_user}","gists_url":"https://api.github.com/users/susanlinsfu/gists{/gist_id}","starred_url":"https://api.github.com/users/susanlinsfu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/susanlinsfu/subscriptions","organizations_url":"https://api.github.com/users/susanlinsfu/orgs","repos_url":"https://api.github.com/users/susanlinsfu/repos","events_url":"https://api.github.com/users/susanlinsfu/events{/privacy}","received_events_url":"https://api.github.com/users/susanlinsfu/received_events","type":"User","site_admin":false},"created_at":"2016-04-26T22:09:43Z","updated_at":"2016-04-26T22:09:43Z","body":"I'm sorry I am not quite following. So with the code I provided would there be a way to modify it to know when there are no more results?\r\n\r\nCheers"}}