In Google Datastore, is it possible to get the cursor for a specific item?
It is possible to use Datastore.key to generate a new key for an element:
const taskKey = datastore.key(['Task', 'sampleTask']);
When running a query, we may get an endCursor that can be used to get the next results.
The cursor is some base64 encoded token that contains the project ID, kind, and key of the last element fetched, with a little bit of unknown binary data.
Would there be a way/method to get that base64 cursor value given the key of an item and kind+project ID?
add a comment |
It is possible to use Datastore.key to generate a new key for an element:
const taskKey = datastore.key(['Task', 'sampleTask']);
When running a query, we may get an endCursor that can be used to get the next results.
The cursor is some base64 encoded token that contains the project ID, kind, and key of the last element fetched, with a little bit of unknown binary data.
Would there be a way/method to get that base64 cursor value given the key of an item and kind+project ID?
add a comment |
It is possible to use Datastore.key to generate a new key for an element:
const taskKey = datastore.key(['Task', 'sampleTask']);
When running a query, we may get an endCursor that can be used to get the next results.
The cursor is some base64 encoded token that contains the project ID, kind, and key of the last element fetched, with a little bit of unknown binary data.
Would there be a way/method to get that base64 cursor value given the key of an item and kind+project ID?
It is possible to use Datastore.key to generate a new key for an element:
const taskKey = datastore.key(['Task', 'sampleTask']);
When running a query, we may get an endCursor that can be used to get the next results.
The cursor is some base64 encoded token that contains the project ID, kind, and key of the last element fetched, with a little bit of unknown binary data.
Would there be a way/method to get that base64 cursor value given the key of an item and kind+project ID?
asked Nov 13 at 5:40
ben
3022418
3022418
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
No, it's not possible.
Or I should rather say that it doesn't make much sense to (attempt to) obtain a cursor from an entity by itself because a cursor only has meaning in the context of the original query from which it was obtained. From Limitations of cursors (emphasis mine):
Cursors are subject to the following limitations:
- A cursor can be used only by the same application that performed the original query, and only to continue the same query. To use the cursor
in a subsequent retrieval operation, you must reconstitute the
original query exactly, including the same entity kind, ancestor
filter, property filters, and sort orders. It is not possible to
retrieve results using a cursor without setting up the same query from
which it was originally generated.
Also from Cursors and data updates:
The cursor's position is defined as the location in the result list
after the last result returned. A cursor is not a relative position in
the list (it's not an offset); it's a marker to which Cloud Datastore
can jump when starting an index scan for results.
Do you know it's not possible for sure or are you trying to argue that it doesn't make sense? It makes sense to me to have a way to be able to infer a cursor value from an entry. That's what dynamodb does and it's pretty useful.
– ben
Nov 14 at 1:29
Both, in the particular datastore context. There was a post which I can't locate with someone actually attempting to do that, based on a similar (or the same?) observation. The quotes, I believe, clarify that what you desire/expect is not possible with the datastore.
– Dan Cornilescu
Nov 14 at 2:13
add a comment |
As previously answered, it's not possible to infer a cursor from a key because a cursor is tied to a query. You can however, filter your queries by key. E.g. select * from Task where key > Key(Task, 'sampleTask')
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53274510%2fin-google-datastore-is-it-possible-to-get-the-cursor-for-a-specific-item%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
No, it's not possible.
Or I should rather say that it doesn't make much sense to (attempt to) obtain a cursor from an entity by itself because a cursor only has meaning in the context of the original query from which it was obtained. From Limitations of cursors (emphasis mine):
Cursors are subject to the following limitations:
- A cursor can be used only by the same application that performed the original query, and only to continue the same query. To use the cursor
in a subsequent retrieval operation, you must reconstitute the
original query exactly, including the same entity kind, ancestor
filter, property filters, and sort orders. It is not possible to
retrieve results using a cursor without setting up the same query from
which it was originally generated.
Also from Cursors and data updates:
The cursor's position is defined as the location in the result list
after the last result returned. A cursor is not a relative position in
the list (it's not an offset); it's a marker to which Cloud Datastore
can jump when starting an index scan for results.
Do you know it's not possible for sure or are you trying to argue that it doesn't make sense? It makes sense to me to have a way to be able to infer a cursor value from an entry. That's what dynamodb does and it's pretty useful.
– ben
Nov 14 at 1:29
Both, in the particular datastore context. There was a post which I can't locate with someone actually attempting to do that, based on a similar (or the same?) observation. The quotes, I believe, clarify that what you desire/expect is not possible with the datastore.
– Dan Cornilescu
Nov 14 at 2:13
add a comment |
No, it's not possible.
Or I should rather say that it doesn't make much sense to (attempt to) obtain a cursor from an entity by itself because a cursor only has meaning in the context of the original query from which it was obtained. From Limitations of cursors (emphasis mine):
Cursors are subject to the following limitations:
- A cursor can be used only by the same application that performed the original query, and only to continue the same query. To use the cursor
in a subsequent retrieval operation, you must reconstitute the
original query exactly, including the same entity kind, ancestor
filter, property filters, and sort orders. It is not possible to
retrieve results using a cursor without setting up the same query from
which it was originally generated.
Also from Cursors and data updates:
The cursor's position is defined as the location in the result list
after the last result returned. A cursor is not a relative position in
the list (it's not an offset); it's a marker to which Cloud Datastore
can jump when starting an index scan for results.
Do you know it's not possible for sure or are you trying to argue that it doesn't make sense? It makes sense to me to have a way to be able to infer a cursor value from an entry. That's what dynamodb does and it's pretty useful.
– ben
Nov 14 at 1:29
Both, in the particular datastore context. There was a post which I can't locate with someone actually attempting to do that, based on a similar (or the same?) observation. The quotes, I believe, clarify that what you desire/expect is not possible with the datastore.
– Dan Cornilescu
Nov 14 at 2:13
add a comment |
No, it's not possible.
Or I should rather say that it doesn't make much sense to (attempt to) obtain a cursor from an entity by itself because a cursor only has meaning in the context of the original query from which it was obtained. From Limitations of cursors (emphasis mine):
Cursors are subject to the following limitations:
- A cursor can be used only by the same application that performed the original query, and only to continue the same query. To use the cursor
in a subsequent retrieval operation, you must reconstitute the
original query exactly, including the same entity kind, ancestor
filter, property filters, and sort orders. It is not possible to
retrieve results using a cursor without setting up the same query from
which it was originally generated.
Also from Cursors and data updates:
The cursor's position is defined as the location in the result list
after the last result returned. A cursor is not a relative position in
the list (it's not an offset); it's a marker to which Cloud Datastore
can jump when starting an index scan for results.
No, it's not possible.
Or I should rather say that it doesn't make much sense to (attempt to) obtain a cursor from an entity by itself because a cursor only has meaning in the context of the original query from which it was obtained. From Limitations of cursors (emphasis mine):
Cursors are subject to the following limitations:
- A cursor can be used only by the same application that performed the original query, and only to continue the same query. To use the cursor
in a subsequent retrieval operation, you must reconstitute the
original query exactly, including the same entity kind, ancestor
filter, property filters, and sort orders. It is not possible to
retrieve results using a cursor without setting up the same query from
which it was originally generated.
Also from Cursors and data updates:
The cursor's position is defined as the location in the result list
after the last result returned. A cursor is not a relative position in
the list (it's not an offset); it's a marker to which Cloud Datastore
can jump when starting an index scan for results.
edited Nov 14 at 2:15
answered Nov 13 at 17:11
Dan Cornilescu
27.5k113161
27.5k113161
Do you know it's not possible for sure or are you trying to argue that it doesn't make sense? It makes sense to me to have a way to be able to infer a cursor value from an entry. That's what dynamodb does and it's pretty useful.
– ben
Nov 14 at 1:29
Both, in the particular datastore context. There was a post which I can't locate with someone actually attempting to do that, based on a similar (or the same?) observation. The quotes, I believe, clarify that what you desire/expect is not possible with the datastore.
– Dan Cornilescu
Nov 14 at 2:13
add a comment |
Do you know it's not possible for sure or are you trying to argue that it doesn't make sense? It makes sense to me to have a way to be able to infer a cursor value from an entry. That's what dynamodb does and it's pretty useful.
– ben
Nov 14 at 1:29
Both, in the particular datastore context. There was a post which I can't locate with someone actually attempting to do that, based on a similar (or the same?) observation. The quotes, I believe, clarify that what you desire/expect is not possible with the datastore.
– Dan Cornilescu
Nov 14 at 2:13
Do you know it's not possible for sure or are you trying to argue that it doesn't make sense? It makes sense to me to have a way to be able to infer a cursor value from an entry. That's what dynamodb does and it's pretty useful.
– ben
Nov 14 at 1:29
Do you know it's not possible for sure or are you trying to argue that it doesn't make sense? It makes sense to me to have a way to be able to infer a cursor value from an entry. That's what dynamodb does and it's pretty useful.
– ben
Nov 14 at 1:29
Both, in the particular datastore context. There was a post which I can't locate with someone actually attempting to do that, based on a similar (or the same?) observation. The quotes, I believe, clarify that what you desire/expect is not possible with the datastore.
– Dan Cornilescu
Nov 14 at 2:13
Both, in the particular datastore context. There was a post which I can't locate with someone actually attempting to do that, based on a similar (or the same?) observation. The quotes, I believe, clarify that what you desire/expect is not possible with the datastore.
– Dan Cornilescu
Nov 14 at 2:13
add a comment |
As previously answered, it's not possible to infer a cursor from a key because a cursor is tied to a query. You can however, filter your queries by key. E.g. select * from Task where key > Key(Task, 'sampleTask')
add a comment |
As previously answered, it's not possible to infer a cursor from a key because a cursor is tied to a query. You can however, filter your queries by key. E.g. select * from Task where key > Key(Task, 'sampleTask')
add a comment |
As previously answered, it's not possible to infer a cursor from a key because a cursor is tied to a query. You can however, filter your queries by key. E.g. select * from Task where key > Key(Task, 'sampleTask')
As previously answered, it's not possible to infer a cursor from a key because a cursor is tied to a query. You can however, filter your queries by key. E.g. select * from Task where key > Key(Task, 'sampleTask')
answered Nov 17 at 0:14
Jim Morrison
62615
62615
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53274510%2fin-google-datastore-is-it-possible-to-get-the-cursor-for-a-specific-item%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown