Google DataStore - createdAt attribute and updates












0














It's often very useful to know when an entry / document has been created. But since it's not possible to update only a specific set of attributes in Google DataStore, it's hard to keep the value of createdAt over the life of the object.



Essentially it seems like in order to have a createdAt attribute with DataStore, the application must [get] the entry in order to retrieve the createdAt value, and then [update] it reusing that value. Of course this means more $$$ since every update will make 2 API requests instead of 1.



Is there something I am missing or is that the best way to go about this?










share|improve this question






















  • an entry / document has been created - do you mean a datastore entity?
    – Dan Cornilescu
    Nov 23 at 3:13
















0














It's often very useful to know when an entry / document has been created. But since it's not possible to update only a specific set of attributes in Google DataStore, it's hard to keep the value of createdAt over the life of the object.



Essentially it seems like in order to have a createdAt attribute with DataStore, the application must [get] the entry in order to retrieve the createdAt value, and then [update] it reusing that value. Of course this means more $$$ since every update will make 2 API requests instead of 1.



Is there something I am missing or is that the best way to go about this?










share|improve this question






















  • an entry / document has been created - do you mean a datastore entity?
    – Dan Cornilescu
    Nov 23 at 3:13














0












0








0







It's often very useful to know when an entry / document has been created. But since it's not possible to update only a specific set of attributes in Google DataStore, it's hard to keep the value of createdAt over the life of the object.



Essentially it seems like in order to have a createdAt attribute with DataStore, the application must [get] the entry in order to retrieve the createdAt value, and then [update] it reusing that value. Of course this means more $$$ since every update will make 2 API requests instead of 1.



Is there something I am missing or is that the best way to go about this?










share|improve this question













It's often very useful to know when an entry / document has been created. But since it's not possible to update only a specific set of attributes in Google DataStore, it's hard to keep the value of createdAt over the life of the object.



Essentially it seems like in order to have a createdAt attribute with DataStore, the application must [get] the entry in order to retrieve the createdAt value, and then [update] it reusing that value. Of course this means more $$$ since every update will make 2 API requests instead of 1.



Is there something I am missing or is that the best way to go about this?







google-cloud-datastore






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 22 at 23:59









ben

3022418




3022418












  • an entry / document has been created - do you mean a datastore entity?
    – Dan Cornilescu
    Nov 23 at 3:13


















  • an entry / document has been created - do you mean a datastore entity?
    – Dan Cornilescu
    Nov 23 at 3:13
















an entry / document has been created - do you mean a datastore entity?
– Dan Cornilescu
Nov 23 at 3:13




an entry / document has been created - do you mean a datastore entity?
– Dan Cornilescu
Nov 23 at 3:13












1 Answer
1






active

oldest

votes


















0














Support for such functionality depends on the client library you use.



For example the ndb client library recommended for the 1st generation App Engine applications offers such support. From Date and Time Properties:




Each of these properties has two extra Boolean keyword options:



auto_now_add



Set property to current date/time when entity is created. You can
manually override this property. When the entity is updated, the
property doesn't change. For that behavior, use auto_now.



auto_now



Set property to current date/time when entity is created and whenever
it is updated.




So when you put the entity into the datastore without providing values for such properties (and they have these options set) they are automatically updated.






share|improve this answer





















  • is this the only client lib that offer such support? In particular, does nodejs have an equivalent lib?
    – ben
    Nov 26 at 8:04











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
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53439240%2fgoogle-datastore-createdat-attribute-and-updates%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














Support for such functionality depends on the client library you use.



For example the ndb client library recommended for the 1st generation App Engine applications offers such support. From Date and Time Properties:




Each of these properties has two extra Boolean keyword options:



auto_now_add



Set property to current date/time when entity is created. You can
manually override this property. When the entity is updated, the
property doesn't change. For that behavior, use auto_now.



auto_now



Set property to current date/time when entity is created and whenever
it is updated.




So when you put the entity into the datastore without providing values for such properties (and they have these options set) they are automatically updated.






share|improve this answer





















  • is this the only client lib that offer such support? In particular, does nodejs have an equivalent lib?
    – ben
    Nov 26 at 8:04
















0














Support for such functionality depends on the client library you use.



For example the ndb client library recommended for the 1st generation App Engine applications offers such support. From Date and Time Properties:




Each of these properties has two extra Boolean keyword options:



auto_now_add



Set property to current date/time when entity is created. You can
manually override this property. When the entity is updated, the
property doesn't change. For that behavior, use auto_now.



auto_now



Set property to current date/time when entity is created and whenever
it is updated.




So when you put the entity into the datastore without providing values for such properties (and they have these options set) they are automatically updated.






share|improve this answer





















  • is this the only client lib that offer such support? In particular, does nodejs have an equivalent lib?
    – ben
    Nov 26 at 8:04














0












0








0






Support for such functionality depends on the client library you use.



For example the ndb client library recommended for the 1st generation App Engine applications offers such support. From Date and Time Properties:




Each of these properties has two extra Boolean keyword options:



auto_now_add



Set property to current date/time when entity is created. You can
manually override this property. When the entity is updated, the
property doesn't change. For that behavior, use auto_now.



auto_now



Set property to current date/time when entity is created and whenever
it is updated.




So when you put the entity into the datastore without providing values for such properties (and they have these options set) they are automatically updated.






share|improve this answer












Support for such functionality depends on the client library you use.



For example the ndb client library recommended for the 1st generation App Engine applications offers such support. From Date and Time Properties:




Each of these properties has two extra Boolean keyword options:



auto_now_add



Set property to current date/time when entity is created. You can
manually override this property. When the entity is updated, the
property doesn't change. For that behavior, use auto_now.



auto_now



Set property to current date/time when entity is created and whenever
it is updated.




So when you put the entity into the datastore without providing values for such properties (and they have these options set) they are automatically updated.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 23 at 3:35









Dan Cornilescu

27.6k113161




27.6k113161












  • is this the only client lib that offer such support? In particular, does nodejs have an equivalent lib?
    – ben
    Nov 26 at 8:04


















  • is this the only client lib that offer such support? In particular, does nodejs have an equivalent lib?
    – ben
    Nov 26 at 8:04
















is this the only client lib that offer such support? In particular, does nodejs have an equivalent lib?
– ben
Nov 26 at 8:04




is this the only client lib that offer such support? In particular, does nodejs have an equivalent lib?
– ben
Nov 26 at 8:04


















draft saved

draft discarded




















































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.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53439240%2fgoogle-datastore-createdat-attribute-and-updates%23new-answer', 'question_page');
}
);

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







Popular posts from this blog

Catalogne

Violoncelliste

Héron pourpré