How to get cursors from each entity in Google Cloud Datastore query?

Viewed 91

I'm working with Google Cloud Datastore in my NodeJS application. When I make a query I want to get the cursors for every entity in the response, however, queries only return the end cursor by default. For example when I make a query like:

const query = datastore
    .createQuery(['EntityType'])
    .limit(2)
    .start(start);
const response = await datastore.runQuery(query);

I get a response that looks something like this:

[
    [
        {
            name: "BLAH",
            age: 21
        },
        {
            name: "BLAH",
            age: 26
        }
    ],
    {
        moreResults: "BLAHBLAHBLAH",
        endCursor: "BLAH2"
    }
]

Is there a way to get the cursor for every entity in the response? For example I want my response to look something like this:

[
    [
        {
            name: "BLAH",
            age: 21,
            cursor: "BLAH1"
        },
        {
            name: "BLAH",
            age: 26,
            cursor: "BLAH2"
        }
    ],
    {
        moreResults: "BLAHBLAHBLAH",
        endCursor: "BLAH2"
    }
]

1 Answers
Related