Repository navigation
Setting Property value types for Datastore Entities #553
Description
Activity
- addedtype: questionRequest for information or clarification. Not an issue.Request for information or clarification. Not an issue.api: datastoreIssues related to the Datastore API.Issues related to the Datastore API.
on May 8, 2015 I believe you can do this by passing in the actual
Datetype object. Looks like the conversion to the proper type in the request is done here: https://github.com/GoogleCloudPlatform/gcloud-node/blob/bc2b57ce4e2d84a8d2ff722d677ddfe681fc8d00/lib/datastore/entity.js#L380I also think that if you want to distinguish between Int and Double, you can use the
gcloud.datastore.doubleand gcloud.datastore.int` methods (see http://googlecloudplatform.github.io/gcloud-node/#/docs/master/datastore)Ie, this should work
var entry = { "title": "Title", "start": new Date(), "myDouble": gcloud.datastore.double(3.0) }; var ds = gcloud.datastore.dataset(); var key = ds.key(['Entry', 'Foo', 'Todo']); ds.save({ key: key, data: entry }, callback);
Perhaps we should add a few more examples to the
dataset#savedocs to address these different cases.Ah ok, I admit I'm struggling to make sense of the documentation. I think the reason for this is that reading the general Datastore documentation for the first time (https://cloud.google.com/datastore/docs/concepts/entities#Datastore_Properties_and_value_types) makes reference to doing something like:
var entity = { key: { path: [{ kind: 'Employee' }] }, properties: { firstName: { stringValue: 'Antonio' }, lastName: { stringValue: 'Salieri' }, hireDate: { dateTimeValue: '2013-05-14T13:01:00.234Z' }, attendedHrTraining: { booleanValue: true } } }; datastore.commit({ mutation: { insertAutoId: [entity] }, mode: 'NON_TRANSACTIONAL' }).execute(callback);
which uses the googleapis module. Maybe it will help to clarify in the documentation the difference between using the googleapis module vs the gcloud module in Node as I'm finding I'm stumbling across both while searching for Datastore information on Node.
That's a great point @byrneciaran. I'm going to open another issue for us to put a banner saying that we're not the same as the googleapis module... Not sure how else we can clarify this without changing documentation on cloud.google.com (which we shouldn't really do until we hit v1.0). If you have any suggestions, definitely let us know!
I'm going to close out this issue as I think we've answered the question, but feel free to re-open if you think that's a mistake, and follow #554 if you're interested in providing any feedback on the updates we're making to the documentation.
- added 6 commits that reference this issue
on Aug 22, 2022 - added a commit that references this issue
on Sep 27, 2022 21 remaining items
- added a commit that references this issue
on Feb 4, 2026 - added a commit that references this issue
on Feb 5, 2026 - added a commit that references this issue
on Feb 23, 2026 - added a commit that references this issue
on Feb 24, 2026 - added a commit that references this issue
on Feb 26, 2026 - added a commit that references this issue
on Feb 26, 2026 - added a commit that references this issue
on Mar 27, 2026
How do I set Property value types (e.g. dateTimeValue, IntegerValue, etc.) when inserting my entities in the example below. At the moment the Property value types are all set as strings