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

datastore: Support commit mutation methods on top level of dataset #208

Closed
ryanseys opened this issue Sep 12, 2014 · 11 comments · Fixed by #218
Closed

datastore: Support commit mutation methods on top level of dataset #208

ryanseys opened this issue Sep 12, 2014 · 11 comments · Fixed by #218
Assignees
Labels
api: datastore Issues related to the Datastore API. 🚨 This issue needs some love. triage me I really want to be triaged.

Comments

@ryanseys
Copy link
Contributor

Should support commit mutations as top level methods in dataset.
It just makes sense:

dataset.upsert(key, properties, function(err, result) {});
dataset.update(key, properties, function(err, result) {});
dataset.insert(key, properties, function(err, result) {});
dataset.insertAutoId(key, properties, function(err, result) {});
dataset.delete(key, function(err) {});
@stephenplusplus
Copy link
Contributor

+1. Users would probably appreciate explicit control.

And bonus, we support delete already!

@stephenplusplus
Copy link
Contributor

What's the difference between insert and insertAutoId? Will calls to insert with incomplete keys throw an exception? Will calls to insertAutoId throw if there are complete keys?

@ryanseys
Copy link
Contributor Author

From the docs: "To have the Datastore assign a numeric ID automatically, omit both the name and id fields and place the entity in the insertAutoId (JSON) or insert_auto_id (protocol buffers) field of the mutation"

@stephenplusplus
Copy link
Contributor

Sure, but how do you propose we handle our implementation? (The last two questions)

@ryanseys
Copy link
Contributor Author

Will calls to insert with incomplete keys throw an exception?

If we are missing required information from the key, return an error in the callback (don't throw).

Will calls to insertAutoId throw if there are complete keys?

Again, no throwing, use the callback to return errors. An error will occur if they provide too little information, not too much.

@ryanseys
Copy link
Contributor Author

We can assume that if they call insertAutoId, then we just include the information relevant to that call i.e. ignore the name and id fields if they are specified.

@stephenplusplus
Copy link
Contributor

I think I'm starting to think differently towards this proposal. I like the simplicity of our API. I think that's the point of making this nice abstraction. If we allow direct methods, we give the user too many options imo, and would be better recommending they use another library/combination of libraries for lower level access.

@ryanseys
Copy link
Contributor Author

I don't see these as "low level access" but fundamental actions you commit to the data in the datastore. The problem with the current code-generated library is it's too high level. You commit a big json blob and that's interpreted as commands including these mutations.

I'm proposing we extract those commands and give them to the user. Those 5 mutations are all I found. I don't think it's asking for much and it shows the developer what they can/cannot do with the datastore from a storage point of view (querying is a different issue).

@stephenplusplus
Copy link
Contributor

fundamental actions you commit to the data in the datastore.

We provide these actions. upsert, insert, insertAutoId, and update all result in an entity being inserted or updated, and these are all handled with save. I don't consider save to be doing much magic. You get the results you intend, based on what you provide.

upsert: "I want to update this entity if it exists, otherwise create one."
save: "give me a complete key or incomplete key"

insert: "I want to insert this entity into the datastore."
save: "give me a complete key or incomplete key"

insertAutoId: "I want to create this entity and have an id generated for me."
save: "give me an incomplete key"

update: "I want to update this entity"
save: "give me a complete key"

So, I don't consider save a limiting factor. I think we would end up overwhelming the user by providing too many methods.

I'm proposing we extract those commands and give them to the user.

Maybe we can show the user more explicitly in our documentation how save works based on what it is given.

@ryanseys
Copy link
Contributor Author

I didn't know save was doing all this. Yeah, an easy way to better the documentation is inline provide a bunch of complete / incomplete keys and what their effect on the datastore will be (i.e. create, update, autoId, etc)

stephenplusplus added a commit to stephenplusplus/gcloud-node that referenced this issue Sep 17, 2014
By default, property index values are set to `true`, without allowing
the user to specify an override. Now, when a user passes in an array
to `dataset.save`, they will have the option of setting `true` or
`false`.

Example:

dataset.save({
  key: dataset.key('Company'),
  data: [
    name: 'propertyName',
    value: 'any value type',
    indexed: false
  ]
}, function(err, keys) {}).

Resolves: googleapis#208
Related: http://goo.gl/tKVvhP
stephenplusplus added a commit to stephenplusplus/gcloud-node that referenced this issue Sep 17, 2014
By default, property index values are set to `true`, without allowing
the user to specify an override. Now, when a user passes in an array
to `dataset.save`, they will have the option of setting `true` or
`false`.

Example:

dataset.save({
  key: dataset.key('Company'),
  data: [
    name: 'propertyName',
    value: 'any value type',
    indexed: false
  ]
}, function(err, keys) {}).

Resolves: googleapis#208
Related: http://goo.gl/tKVvhP
stephenplusplus added a commit to stephenplusplus/gcloud-node that referenced this issue Sep 17, 2014
By default, property index values are set to `true`, without allowing
the user to specify an override. Now, when a user passes in an array
to `dataset.save`, they will have the option of setting `true` or
`false`.

Example:

dataset.save({
  key: dataset.key('Company'),
  data: [
    name: 'propertyName',
    value: 'any value type',
    indexed: false
  ]
}, function(err, keys) {}).

Resolves: googleapis#208
Related: http://goo.gl/tKVvhP
stephenplusplus added a commit to stephenplusplus/gcloud-node that referenced this issue Sep 17, 2014
By default, property index values are set to `true`, without allowing
the user to specify an override. Now, when a user passes in an array
to `dataset.save`, they will have the option of setting `true` or
`false`.

Example:

dataset.save({
  key: dataset.key('Company'),
  data: [
    name: 'propertyName',
    value: 'any value type',
    indexed: false
  ]
}, function(err, keys) {}).

Resolves: googleapis#208
Related: http://goo.gl/tKVvhP
@ryanseys
Copy link
Contributor Author

Closing. Seems save does all the magic.

stephenplusplus added a commit to stephenplusplus/gcloud-node that referenced this issue Sep 24, 2014
By default, property index values are set to `true`, without allowing
the user to specify an override. Now, when a user passes in an array
to `dataset.save`, they will have the option of setting `true` or
`false`.

Example:

dataset.save({
  key: dataset.key('Company'),
  data: [
    {
      name: 'propertyName',
      value: 'any value type',
      indexable: false
    }
  ]
}, function(err, keys) {}).

Resolves: googleapis#208
Related: http://goo.gl/tKVvhP
stephenplusplus added a commit to stephenplusplus/gcloud-node that referenced this issue Sep 25, 2014
By default, property index values are set to `true`, without allowing
the user to specify an override. Now, when a user passes in an array
to `dataset.save`, they will have the option of setting `true` or
`false`.

Example:

dataset.save({
  key: dataset.key('Company'),
  data: [
    {
      name: 'propertyName',
      value: 'any value type',
      excludeFromIndexes: false
    }
  ]
}, function(err, keys) {}).

Resolves: googleapis#208
Related: http://goo.gl/tKVvhP
stephenplusplus added a commit to stephenplusplus/gcloud-node that referenced this issue Sep 25, 2014
By default, property index values are set to `true`, without allowing
the user to specify an override. Now, when a user passes in an array
to `dataset.save`, they will have the option of setting `true` or
`false`.

Example:

dataset.save({
  key: dataset.key('Company'),
  data: [
    {
      name: 'propertyName',
      value: 'any value type',
      excludeFromIndexes: false
    }
  ]
}, function(err, keys) {}).

Resolves: googleapis#208
Related: http://goo.gl/tKVvhP
stephenplusplus added a commit to stephenplusplus/gcloud-node that referenced this issue Sep 27, 2014
By default, property index values are set to `true`, without allowing
the user to specify an override. Now, when a user passes in an array
to `dataset.save`, they will have the option of setting `true` or
`false`.

Example:

dataset.save({
  key: dataset.key('Company'),
  data: [
    {
      name: 'propertyName',
      value: 'any value type',
      excludeFromIndexes: false
    }
  ]
}, function(err, keys) {}).

Resolves: googleapis#208
Related: http://goo.gl/tKVvhP
stephenplusplus added a commit to stephenplusplus/gcloud-node that referenced this issue Sep 27, 2014
By default, property index values are set to `true`, without allowing
the user to specify an override. Now, when a user passes in an array
to `dataset.save`, they will have the option of setting `true` or
`false`.

Example:

dataset.save({
  key: dataset.key('Company'),
  data: [
    {
      name: 'propertyName',
      value: 'any value type',
      excludeFromIndexes: false
    }
  ]
}, function(err, keys) {}).

Resolves: googleapis#208
Related: http://goo.gl/tKVvhP
stephenplusplus added a commit to stephenplusplus/gcloud-node that referenced this issue Sep 29, 2014
By default, property index values are set to `true`, without allowing
the user to specify an override. Now, when a user passes in an array
to `dataset.save`, they will have the option of setting `true` or
`false`.

Example:

dataset.save({
  key: dataset.key('Company'),
  data: [
    {
      name: 'propertyName',
      value: 'any value type',
      excludeFromIndexes: false
    }
  ]
}, function(err, keys) {}).

Resolves: googleapis#208
Related: http://goo.gl/tKVvhP
stephenplusplus added a commit to stephenplusplus/gcloud-node that referenced this issue Sep 29, 2014
By default, property index values are set to `true`, without allowing
the user to specify an override. Now, when a user passes in an array
to `dataset.save`, they will have the option of setting `true` or
`false`.

Example:

dataset.save({
  key: dataset.key('Company'),
  data: [
    {
      name: 'propertyName',
      value: 'any value type',
      excludeFromIndexes: false
    }
  ]
}, function(err, keys) {}).

Resolves: googleapis#208
Related: http://goo.gl/tKVvhP
stephenplusplus added a commit to stephenplusplus/gcloud-node that referenced this issue Sep 29, 2014
By default, property index values are set to `true`, without allowing
the user to specify an override. Now, when a user passes in an array
to `dataset.save`, they will have the option of setting `true` or
`false`.

Example:

dataset.save({
  key: dataset.key('Company'),
  data: [
    {
      name: 'propertyName',
      value: 'any value type',
      excludeFromIndexes: false
    }
  ]
}, function(err, keys) {}).

Resolves: googleapis#208
Related: http://goo.gl/tKVvhP
stephenplusplus added a commit to stephenplusplus/gcloud-node that referenced this issue Sep 30, 2014
By default, property index values are set to `true`, without allowing
the user to specify an override. Now, when a user passes in an array
to `dataset.save`, they will have the option of setting `true` or
`false`.

Example:

dataset.save({
  key: dataset.key('Company'),
  data: [
    {
      name: 'propertyName',
      value: 'any value type',
      excludeFromIndexes: false
    }
  ]
}, function(err, keys) {}).

Resolves: googleapis#208
Related: http://goo.gl/tKVvhP
stephenplusplus added a commit to stephenplusplus/gcloud-node that referenced this issue Sep 30, 2014
By default, property index values are set to `true`, without allowing
the user to specify an override. Now, when a user passes in an array
to `dataset.save`, they will have the option of setting `true` or
`false`.

Example:

dataset.save({
  key: dataset.key('Company'),
  data: [
    {
      name: 'propertyName',
      value: 'any value type',
      excludeFromIndexes: false
    }
  ]
}, function(err, keys) {}).

Resolves: googleapis#208
Related: http://goo.gl/tKVvhP
@jgeewax jgeewax added the api: datastore Issues related to the Datastore API. label Feb 2, 2015
@jgeewax jgeewax added this to the Datastore Stable milestone Feb 2, 2015
@yoshi-automation yoshi-automation added the triage me I really want to be triaged. label Apr 6, 2020
sofisl pushed a commit that referenced this issue Nov 11, 2022
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
sofisl pushed a commit that referenced this issue Nov 11, 2022
…PI (#208)

* feat: add `runFunnelReport` method to the Alpha version of the Data API

PiperOrigin-RevId: 446813357

Source-Link: googleapis/googleapis@6d3ae1a

Source-Link: googleapis/googleapis-gen@1cfc0eb
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMWNmYzBlYjY2ODc0ZjA1YzQxODJkNDIyZTFjODliZDVlMmYyYWJlNyJ9

* 🦉 Updates from OwlBot post-processor

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
sofisl pushed a commit that referenced this issue Nov 11, 2022
…imated bytes that a session will scan. (#208)

Committer: @emkornfield
PiperOrigin-RevId: 396849937
sofisl pushed a commit that referenced this issue Nov 11, 2022
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [jsdoc-fresh](https://togithub.com/googleapis/jsdoc-fresh) | [`^1.0.2` -> `^2.0.0`](https://renovatebot.com/diffs/npm/jsdoc-fresh/1.1.1/2.0.0) | [![age](https://badges.renovateapi.com/packages/npm/jsdoc-fresh/2.0.0/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/npm/jsdoc-fresh/2.0.0/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/npm/jsdoc-fresh/2.0.0/compatibility-slim/1.1.1)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/npm/jsdoc-fresh/2.0.0/confidence-slim/1.1.1)](https://docs.renovatebot.com/merge-confidence/) |

---

### Release Notes

<details>
<summary>googleapis/jsdoc-fresh</summary>

### [`v2.0.0`](https://togithub.com/googleapis/jsdoc-fresh/blob/HEAD/CHANGELOG.md#&#8203;200-httpsgithubcomgoogleapisjsdoc-freshcomparev111v200-2022-05-18)

[Compare Source](https://togithub.com/googleapis/jsdoc-fresh/compare/v1.1.1...v2.0.0)

##### ⚠ BREAKING CHANGES

-   update library to use Node 12 ([#&#8203;108](https://togithub.com/googleapis/jsdoc-fresh/issues/108))

##### Build System

-   update library to use Node 12 ([#&#8203;108](https://togithub.com/googleapis/jsdoc-fresh/issues/108)) ([e61c223](https://togithub.com/googleapis/jsdoc-fresh/commit/e61c2238db8900e339e5fe7fb8aea09642290182))

##### [1.1.1](https://www.github.com/googleapis/jsdoc-fresh/compare/v1.1.0...v1.1.1) (2021-08-11)

##### Bug Fixes

-   **build:** migrate to using main branch ([#&#8203;83](https://www.togithub.com/googleapis/jsdoc-fresh/issues/83)) ([9474adb](https://www.github.com/googleapis/jsdoc-fresh/commit/9474adbf0d559d319ff207397ba2be6b557999ac))

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "after 9am and before 3pm" (UTC), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, click this checkbox.

---

This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/googleapis/nodejs-analytics-admin).
sofisl pushed a commit that referenced this issue Nov 16, 2022
fix: use google-gax v3.3.0
Source-Link: googleapis/synthtool@c73d112
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-nodejs:latest@sha256:b15a6f06cc06dcffa11e1bebdf1a74b6775a134aac24a0f86f51ddf728eb373e
sofisl pushed a commit that referenced this issue Nov 18, 2022
sofisl pushed a commit that referenced this issue Jan 26, 2023
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
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. 🚨 This issue needs some love. triage me I really want to be triaged.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants