Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting Property value types for Datastore Entities #553

Closed
byrneciaran opened this issue May 8, 2015 · 4 comments
Closed

Setting Property value types for Datastore Entities #553

byrneciaran opened this issue May 8, 2015 · 4 comments
Assignees
Labels
api: datastore Issues related to the Datastore API. type: question Request for information or clarification. Not an issue.

Comments

@byrneciaran
Copy link

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

var entry = {
    "title":"Title",
    "start":"2014-02-01T09:28:56.321-10:00"
};

var ds = gcloud.datastore.dataset();
var key = ds.key(['Entry', 'Foo', 'Todo']);

ds.save({
    key: key,
    data: entry
}, callback);
@jgeewax jgeewax added type: question Request for information or clarification. Not an issue. api: datastore Issues related to the Datastore API. labels May 8, 2015
@jgeewax
Copy link
Contributor

jgeewax commented May 8, 2015

I believe you can do this by passing in the actual Date type 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#L380

I also think that if you want to distinguish between Int and Double, you can use the gcloud.datastore.double and 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);

@ryanseys
Copy link
Contributor

ryanseys commented May 8, 2015

Perhaps we should add a few more examples to the dataset#save docs to address these different cases.

@byrneciaran
Copy link
Author

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.

@jgeewax
Copy link
Contributor

jgeewax commented May 8, 2015

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.

@jgeewax jgeewax closed this as completed May 8, 2015
chingor13 pushed a commit that referenced this issue Aug 22, 2022
* feat: add OSConfigZonalService API Committer: @jaiminsh

PiperOrigin-RevId: 394704298

Source-Link: googleapis/googleapis@31d2d34

Source-Link: googleapis/googleapis-gen@aa3ce09

* 🦉 Updates from OwlBot

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
chingor13 pushed a commit that referenced this issue Aug 22, 2022
🤖 I have created a release \*beep\* \*boop\*
---
## [3.19.0](https://www.github.com/googleapis/nodejs-asset/compare/v3.18.0...v3.19.0) (2021-09-07)


### Features

* add OSConfigZonalService API Committer: [@jaiminsh](https://www.github.com/jaiminsh) ([#553](https://www.github.com/googleapis/nodejs-asset/issues/553)) ([1ab2458](https://www.github.com/googleapis/nodejs-asset/commit/1ab2458b63ebe46b8aa8edbd2b1837e793d531f1))
* Release of relationships in v1, Add content type Relationship to support relationship search Committer: yuwangyw@ ([#551](https://www.github.com/googleapis/nodejs-asset/issues/551)) ([56526b0](https://www.github.com/googleapis/nodejs-asset/commit/56526b02d14d15fd6fc469cd614bff9098f3789b))
---


This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
chingor13 pushed a commit that referenced this issue Aug 22, 2022
* feat: add OSConfigZonalService API Committer: @jaiminsh

PiperOrigin-RevId: 394704298

Source-Link: googleapis/googleapis@31d2d34

Source-Link: googleapis/googleapis-gen@aa3ce09

* 🦉 Updates from OwlBot

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
chingor13 pushed a commit that referenced this issue Aug 22, 2022
🤖 I have created a release \*beep\* \*boop\*
---
## [3.19.0](https://www.github.com/googleapis/nodejs-asset/compare/v3.18.0...v3.19.0) (2021-09-07)


### Features

* add OSConfigZonalService API Committer: [@jaiminsh](https://www.github.com/jaiminsh) ([#553](https://www.github.com/googleapis/nodejs-asset/issues/553)) ([1ab2458](https://www.github.com/googleapis/nodejs-asset/commit/1ab2458b63ebe46b8aa8edbd2b1837e793d531f1))
* Release of relationships in v1, Add content type Relationship to support relationship search Committer: yuwangyw@ ([#551](https://www.github.com/googleapis/nodejs-asset/issues/551)) ([56526b0](https://www.github.com/googleapis/nodejs-asset/commit/56526b02d14d15fd6fc469cd614bff9098f3789b))
---


This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
chingor13 pushed a commit that referenced this issue Aug 22, 2022
* feat: add OSConfigZonalService API Committer: @jaiminsh

PiperOrigin-RevId: 394704298

Source-Link: googleapis/googleapis@31d2d34

Source-Link: googleapis/googleapis-gen@aa3ce09

* 🦉 Updates from OwlBot

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
chingor13 pushed a commit that referenced this issue Aug 22, 2022
🤖 I have created a release \*beep\* \*boop\*
---
## [3.19.0](https://www.github.com/googleapis/nodejs-asset/compare/v3.18.0...v3.19.0) (2021-09-07)


### Features

* add OSConfigZonalService API Committer: [@jaiminsh](https://www.github.com/jaiminsh) ([#553](https://www.github.com/googleapis/nodejs-asset/issues/553)) ([1ab2458](https://www.github.com/googleapis/nodejs-asset/commit/1ab2458b63ebe46b8aa8edbd2b1837e793d531f1))
* Release of relationships in v1, Add content type Relationship to support relationship search Committer: yuwangyw@ ([#551](https://www.github.com/googleapis/nodejs-asset/issues/551)) ([56526b0](https://www.github.com/googleapis/nodejs-asset/commit/56526b02d14d15fd6fc469cd614bff9098f3789b))
---


This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
sofisl pushed a commit that referenced this issue Sep 27, 2022
sofisl pushed a commit that referenced this issue Oct 11, 2022
Co-authored-by: gcf-owl-bot[bot] <78513119+gcf-owl-bot[bot]@users.noreply.github.com>
Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
sofisl pushed a commit that referenced this issue Oct 13, 2022
Co-authored-by: gcf-owl-bot[bot] <78513119+gcf-owl-bot[bot]@users.noreply.github.com>
Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
sofisl pushed a commit that referenced this issue Nov 9, 2022
sofisl pushed a commit that referenced this issue Nov 10, 2022
sofisl pushed a commit that referenced this issue Nov 11, 2022
sofisl pushed a commit that referenced this issue Nov 11, 2022
* feat: add OSConfigZonalService API Committer: @jaiminsh

PiperOrigin-RevId: 394704298

Source-Link: googleapis/googleapis@31d2d34

Source-Link: googleapis/googleapis-gen@aa3ce09

* 🦉 Updates from OwlBot

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
sofisl pushed a commit that referenced this issue Nov 11, 2022
🤖 I have created a release \*beep\* \*boop\*
---
## [3.19.0](https://www.github.com/googleapis/nodejs-asset/compare/v3.18.0...v3.19.0) (2021-09-07)


### Features

* add OSConfigZonalService API Committer: [@jaiminsh](https://www.github.com/jaiminsh) ([#553](https://www.github.com/googleapis/nodejs-asset/issues/553)) ([1ab2458](https://www.github.com/googleapis/nodejs-asset/commit/1ab2458b63ebe46b8aa8edbd2b1837e793d531f1))
* Release of relationships in v1, Add content type Relationship to support relationship search Committer: yuwangyw@ ([#551](https://www.github.com/googleapis/nodejs-asset/issues/551)) ([56526b0](https://www.github.com/googleapis/nodejs-asset/commit/56526b02d14d15fd6fc469cd614bff9098f3789b))
---


This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
sofisl pushed a commit that referenced this issue Nov 17, 2022
* docs: Fixes small typo

* docs: Add missing gce_startup_script end comment

* lint fix

* copyright fix

Co-authored-by: Takashi Matsuo <tmatsuo@google.com>
sofisl pushed a commit that referenced this issue Jan 10, 2023
This PR was generated using Autosynth. 🌈

Synth log will be available here:
https://source.cloud.google.com/results/invocations/160598ca-4f95-425c-8b33-df656c4049e4/targets

- [ ] To automatically regenerate this PR, check this box.

Source-Link: googleapis/synthtool@901ddd4
Source-Link: googleapis/synthtool@f96d3b4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: datastore Issues related to the Datastore API. type: question Request for information or clarification. Not an issue.
Projects
None yet
Development

No branches or pull requests

3 participants