GeezerVison is showing github.com — How are query start cursorTokens used? · Issue #1208 · googleapis/google-cloud-node
How are query start cursorTokens used? #1208DescriptionMy application is using express and I'm having some troubles getting the latest ~0.30.0 releases to return a cursor value I can pass back to the client for usage. If I recall correctly the previous releases were using a base64 string. What kind of cursorToken should I be passing a start query now?
https://googlecloudplatform.github.io/gcloud-node/#/docs/v0.30.2/datastore/query?method=start
datastore.runQuery(
datastore.createQuery('User').start(???).limit(1),
function(error, entities, cursor) {
// cursor used to return base64 startVal
}
);
Maybe I should manually convert it myself now?
new Buffer(cursor.startVal).toString('base64')
Activitymcfarljw commented on Apr 6, 2016 ContributorAuthor More actions I've just spent a bit of time looking into the issue and did get it working. Here is what I came up with:
var cursorToken = req.cursorToken ? new Buffer(req.cursorToken, 'base64') : null;
datastore.runQuery(
datastore.createQuery('User').start(cursorToken).limit(1),
function(error, entities, nextQuery) {
var result = {};
result.cursorToken = new Buffer(nextQuery.startVal).toString('base64');
res.status(200).json(result);
);
It might make things a bit more straightforward and easier to work with if the start method would accept both base64 and buffer parameters. It might also be convenient for the nextQuery to include a base64 version called endCursorToken and startCursorToken so that it matches up a bit more with the documentation. stephenplusplus commented on Apr 6, 2016 I think we should just go back to only accepting base64 strings and skip buffers altogether. Any interest in putting a PR together? mcfarljw commented on Apr 6, 2016 ContributorAuthor More actions I'll take a shot at making a PR for this and see what happens. stephenplusplus commented on Apr 6, 2016 Thanks! Feel free to send it in even if it's not perfect. I can always help with the grunt work (code style, tests, etc). stephenplusplus commented on Apr 7, 2016
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|