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

feat(datastore): support setting a property indexed value #218

Merged

Conversation

stephenplusplus
Copy link
Contributor

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: true
  ]
}, function(err, keys) {}).

Resolves: #208
Related: http://goo.gl/tKVvhP

* is returned to the callback.
*
* This method automatically handles the `upsert`, `insert`, `update`, and
* `insertAutoId` Datastore methods.

This comment was marked as spam.

This comment was marked as spam.

@silvolu
Copy link
Contributor

silvolu commented Sep 23, 2014

LGTM, other opinions on this change?

@pcostell
Copy link
Contributor

Indexed is likely not the best way to describe this. In particular, its usage in many of the other APIs has caused confusion due to its interaction with composite indexes. What this flag really should indicate is that the specific value cannot be indexed (i.e. a blob or string that is too long). The Cloud Datastore API has changed this flag to "exclude_from_indexes" to make it more verbose. Something that is more readable could be something along the lines of "indexable".

@silvolu
Copy link
Contributor

silvolu commented Sep 24, 2014

I think you're right.
Although more verbose, exclude_from_indexes makes the concept immediately clear, but I don't have any strong opinions.

@stephenplusplus
Copy link
Contributor Author

To make sure I'm understanding, this PR would work the same way, we just want to change the term indexed to indexable?

If that's correct... is a user providing a 500+ char string and using indexable: false just a way of acknowledging they know the string can't be indexed, thus asking for the property to be committed with indexed: false? (I can't see why indexable is clearer than indexed in this case)

If that's not correct... would someone be able to write up a quick sample of what our api should look like and the effect that has on the resulting commit api call (if any)?

Please excuse my confusion!

Also, should we handle 500+ char strings that are sent in without indexable: false differently than we do currently? e.g. we wouldn't send the api request, instead throw an error telling the user if they want to save this, they must use the explicit indexed: false notation.

@silvolu
Copy link
Contributor

silvolu commented Sep 24, 2014

The problem that emerges from the issue linked by @pcostell is that the name indexed is ambiguous.
I would think that if I set it to false for a certain property, the per-property index is not automatically created, but I can still manually define composite indexes that use the property; but this is not true, because setting it to false means that the property should not appear in any indexes.
So indexable is an attempt at making it more clear.

Does it make sense?

Regarding the throwing errors bit, I'd delegate that to the API backend and just make the call and report the error. Did you have a chance to check if the API error message is clear enough?

@stephenplusplus
Copy link
Contributor Author

Thank you, I understand now. 💡 I'll update the PR later and get back with an answer on the API error message clarity.

@stephenplusplus
Copy link
Contributor Author

PTAL.

*
* By default, all properties may be indexed. To prevent a property from being
* used in an index, you must supply an entity's `data` property as an array.
* See below for an example.

This comment was marked as spam.

This comment was marked as spam.

@stephenplusplus
Copy link
Contributor Author

The API error we pass lgtm:

{ [Error: The string property hi has a value that is too long. It cannot exceed 500 characters.]
     errors: [],
     code: 400,
     message: 'The string property hi has a value that is too long. It cannot exceed 500 characters.' } }

@pcostell
Copy link
Contributor

Just to clarify a little when a user would want to use exclude_from_indexes:

  1. As mentioned, if the value cannot be indexed i.e. the string is too long. Yes we could detect this case and just not index the data, but then when the user tries to query on it they wouldn't find that entity.
  2. The data never needs to be queried. For example an encoded image (that's less than 500 bytes). Technically it's still indexable, but there isn't really a point to indexing it.

@stephenplusplus
Copy link
Contributor Author

Thank you for helping me understand :)

I've updated the PR with your wording improvements and also renamed indexable to the more clear excludeFromIndexes. Please let me know if there's room for any more improvements.

it('should not set an indexed value by default', function() {
transaction.makeReq = function(method, req) {
var property = req.mutation.upsert[0].property[0];
assert.strictEqual(property.value.indexed, null);

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

* example, if you provide an incomplete key (one without an ID), the request
* will automatically create a new entity and have its ID assigned. Or, if you
* provide a complete key, the data you pass with it will be used to update the
* entity.

This comment was marked as spam.

This comment was marked as spam.

* example, if you provide an incomplete key (one without an ID), the request
* will create a new entity and have its ID automatically assigned. Or, if you
* provide a complete key, the data you pass with it will be used to update the
* entity.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

@ryanseys
Copy link
Contributor

Other than documentation notes, this LGTM.

@stephenplusplus
Copy link
Contributor Author

PTAL

ent.property = entityObject.data.map(function(data) {
data.value = entity.valueToProperty(data.value);
if (util.is(data.excludeFromIndexes, 'boolean')) {
data.value.indexed = data.excludeFromIndexes;

This comment was marked as spam.

This comment was marked as spam.

sofisl pushed a commit that referenced this pull request Nov 11, 2022
fix!: rename the `funnel_filter` field of the `FunnelFilterExpression` type to `funnel_field_filter`
PiperOrigin-RevId: 455204231
Source-Link: googleapis/googleapis@4849480
Source-Link: googleapis/googleapis-gen@589642d
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNTg5NjQyZDBhNjhhMmM1MTkyNzNjZjBmN2Q3OTQ3YjE5Y2Q5OWVhYyJ9
Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
sofisl pushed a commit that referenced this pull request Nov 11, 2022
This PR was generated using Autosynth. 🌈

Synth log will be available here:
https://source.cloud.google.com/results/invocations/e6ac0f7f-2fc1-4ac2-9eb5-23ba1215b6a2/targets

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

Source-Link: googleapis/synthtool@dc9caca
sofisl pushed a commit that referenced this pull request Nov 11, 2022
chore: relocate owl bot post processor
sofisl pushed a commit that referenced this pull request Nov 11, 2022
sofisl pushed a commit that referenced this pull request Nov 11, 2022
* chore(main): release 4.3.0

* 🦉 Updates from OwlBot post-processor

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

Co-authored-by: release-please[bot] <55107282+release-please[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 pull request Nov 11, 2022
[![WhiteSource Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [gts](https://github.com/google/gts) | [`^2.0.2` -> `^3.0.0`](https://renovatebot.com/diffs/npm/gts/2.0.2/3.1.0) | [![age](https://badges.renovateapi.com/packages/npm/gts/3.1.0/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/npm/gts/3.1.0/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/npm/gts/3.1.0/compatibility-slim/2.0.2)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/npm/gts/3.1.0/confidence-slim/2.0.2)](https://docs.renovatebot.com/merge-confidence/) |

---

### Release Notes

<details>
<summary>google/gts</summary>

### [`v3.1.0`](https://github.com/google/gts/blob/HEAD/CHANGELOG.md#&#8203;310-httpswwwgithubcomgooglegtscomparev303v310-2021-01-11)

[Compare Source](https://github.com/google/gts/compare/v3.0.3...v3.1.0)

##### Features

-   support comments in JSON ([#&#8203;571](https://www.github.com/google/gts/issues/571)) ([cb6d2ca](https://www.github.com/google/gts/commit/cb6d2cacb5de7bcc9c8e82dd47e14fc5bf9596a3))

##### Bug Fixes

-   **deps:** update dependency eslint-config-prettier to v7 ([#&#8203;601](https://www.github.com/google/gts/issues/601)) ([6e26681](https://www.github.com/google/gts/commit/6e266812da4b90b18e2abead9b2b5a1ca0c6654b))
-   **deps:** upgrade to latest version of meow ([#&#8203;616](https://www.github.com/google/gts/issues/616)) ([634bad9](https://www.github.com/google/gts/commit/634bad9bbbdb4d397bba101dc38ab14881172a30))

##### [3.0.3](https://www.github.com/google/gts/compare/v3.0.2...v3.0.3) (2020-12-03)

##### Bug Fixes

-   **deps:** update dependency execa to v5 ([#&#8203;600](https://www.github.com/google/gts/issues/600)) ([4e5f1e5](https://www.github.com/google/gts/commit/4e5f1e54facf53588bbb3b025b5240edbd7f3c8a))
-   **deps:** update dependency meow to v8 ([#&#8203;591](https://www.github.com/google/gts/issues/591)) ([c7e223e](https://www.github.com/google/gts/commit/c7e223e6a2ff605fabad2f8359a0385033f8de66))

##### [3.0.2](https://www.github.com/google/gts/compare/v3.0.1...v3.0.2) (2020-10-26)

##### Bug Fixes

-   **deps:** loosen ts peer dependency ([#&#8203;589](https://www.github.com/google/gts/issues/589)) ([8f1d381](https://www.github.com/google/gts/commit/8f1d381d7b166a510c42786c4a337e81b7222c84))

##### [3.0.1](https://www.github.com/google/gts/compare/v3.0.0...v3.0.1) (2020-10-12)

##### Bug Fixes

-   **rule:** turn off [@&#8203;typescript-eslint/no-var-requires](https://github.com/typescript-eslint/no-var-requires) ([#&#8203;578](https://www.github.com/google/gts/issues/578)) ([3b37229](https://www.github.com/google/gts/commit/3b37229c45969a3c53af123c69bb749578ee6b0b))

### [`v3.0.3`](https://github.com/google/gts/blob/HEAD/CHANGELOG.md#&#8203;303-httpswwwgithubcomgooglegtscomparev302v303-2020-12-03)

[Compare Source](https://github.com/google/gts/compare/v3.0.2...v3.0.3)

### [`v3.0.2`](https://github.com/google/gts/blob/HEAD/CHANGELOG.md#&#8203;302-httpswwwgithubcomgooglegtscomparev301v302-2020-10-26)

[Compare Source](https://github.com/google/gts/compare/v3.0.1...v3.0.2)

### [`v3.0.1`](https://github.com/google/gts/blob/HEAD/CHANGELOG.md#&#8203;301-httpswwwgithubcomgooglegtscomparev300v301-2020-10-12)

[Compare Source](https://github.com/google/gts/compare/v3.0.0...v3.0.1)

### [`v3.0.0`](https://github.com/google/gts/blob/HEAD/CHANGELOG.md#&#8203;300-httpswwwgithubcomgooglegtscomparev202v300-2020-10-08)

[Compare Source](https://github.com/google/gts/compare/v2.0.2...v3.0.0)

##### ⚠ BREAKING CHANGES

-   change default `check` to `lint` ([#&#8203;570](https://github.com/google/gts/issues/570))
-   **deps:** require TypeScript 4.x ([#&#8203;565](https://github.com/google/gts/issues/565))

##### Features

-   Add TypeScript v4 support ([#&#8203;551](https://www.github.com/google/gts/issues/551)) ([0883956](https://www.github.com/google/gts/commit/08839565a1d2b4b39d532c9b0b596f01b18856fe))
-   change default `check` to `lint` ([#&#8203;570](https://www.github.com/google/gts/issues/570)) ([c527b66](https://www.github.com/google/gts/commit/c527b66be1ef6a78ea14b3d29225a8d7fb7097bd))
-   generate .eslintignore when running init ([#&#8203;521](https://www.github.com/google/gts/issues/521)) ([8bce036](https://www.github.com/google/gts/commit/8bce0368767f0c2ad7d0700deb839962bc928d16))

##### Bug Fixes

-   add build/.eslintrc.json to files field ([#&#8203;553](https://www.github.com/google/gts/issues/553)) ([3b516ad](https://www.github.com/google/gts/commit/3b516ad5e9f0d58201dde469461db7c6ed1c1b78))
-   **deps:** require TypeScript 4.x ([#&#8203;565](https://www.github.com/google/gts/issues/565)) ([cbc5267](https://www.github.com/google/gts/commit/cbc5267579ef24e8c8ceaa2ef794df3ef54ea56a))
-   **deps:** update dependency update-notifier to v5 ([#&#8203;574](https://www.github.com/google/gts/issues/574)) ([9a882bf](https://www.github.com/google/gts/commit/9a882bf4ac30ad06e7b91a65ad5721d8e8b41c4b))
-   **deps:** update typescript-eslint monorepo to v2.34.0 ([#&#8203;509](https://www.github.com/google/gts/issues/509)) ([998a4ac](https://www.github.com/google/gts/commit/998a4ac9b75c97f04d8e5db37563f32d31652f23))
-   **deps:** update typescript-eslint monorepo to v3 (major) ([#&#8203;528](https://www.github.com/google/gts/issues/528)) ([e22e173](https://www.github.com/google/gts/commit/e22e17338db2ddb7eb829c821037c2f4e77ff869))
-   **deps:** update typescript-eslint monorepo to v4 ([#&#8203;556](https://www.github.com/google/gts/issues/556)) ([54148df](https://www.github.com/google/gts/commit/54148dfbd8b5f8b36a0f44f901c5db933393a661))
-   better error message for broken tsconfig.json ([#&#8203;501](https://www.github.com/google/gts/issues/501)) ([0c17a76](https://www.github.com/google/gts/commit/0c17a76c6650eee1d8abaff11a897a432eeaa65f))
-   prohibit calls for it.only and describe.only ([#&#8203;499](https://www.github.com/google/gts/issues/499)) ([071c33c](https://www.github.com/google/gts/commit/071c33ceef0e3765166aaebf6ed4698167ac0f98))

##### [2.0.2](https://www.github.com/google/gts/compare/v2.0.1...v2.0.2) (2020-05-11)

##### Bug Fixes

-   Revert 'update dependency eslint to v7'" ([#&#8203;507](https://www.github.com/google/gts/issues/507)) ([0f9950b](https://www.github.com/google/gts/commit/0f9950b273329dbcce5f3cc20864c3dcd076f08c))
-   **deps:** pin release of eslint-typescript ([#&#8203;508](https://www.github.com/google/gts/issues/508)) ([bd86b42](https://www.github.com/google/gts/commit/bd86b42e2bb904d3765dee82262e4691a11b9958))
-   **deps:** update dependency eslint to v7 ([#&#8203;504](https://www.github.com/google/gts/issues/504)) ([6aee159](https://www.github.com/google/gts/commit/6aee1595d0486ae2c7fd68d16b1b59c4c4015753))

##### [2.0.1](https://www.github.com/google/gts/compare/v2.0.0...v2.0.1) (2020-05-07)

##### Bug Fixes

-   throw an error if running with an unsupported version of nodejs ([#&#8203;493](https://www.github.com/google/gts/issues/493)) ([94fdf1e](https://www.github.com/google/gts/commit/94fdf1eaed634aa73c3e44c7a3d9f1325f773b07))
-   **deps:** update dependency meow to v7 ([#&#8203;502](https://www.github.com/google/gts/issues/502)) ([cf91cda](https://www.github.com/google/gts/commit/cf91cda1afab25759427511d3c97d0037d61c649))

</details>

---

### Configuration

📅 **Schedule**: "after 9am and before 3pm" (UTC).

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

♻ **Rebasing**: Renovate will not automatically rebase this PR, because other commits have been found.

🔕 **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 [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#github/googleapis/nodejs-dialogflow-cx).
@release-please release-please bot mentioned this pull request Nov 12, 2022
sofisl pushed a commit that referenced this pull request Nov 16, 2022
- [ ] Regenerate this pull request now.

PiperOrigin-RevId: 477369320

Source-Link: googleapis/googleapis@6954c4d

Source-Link: googleapis/googleapis-gen@81e5272
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiODFlNTI3MjY3MWJkMWM1YzhhYzE1YTQ0YmQyNTkyMmYwYjkzZWFlNiJ9

chore: override API mixins when needed
PiperOrigin-RevId: 477248447

Source-Link: googleapis/googleapis@4689c73

Source-Link: googleapis/googleapis-gen@c405978
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYzQwNTk3ODZhNWNkODA1YTAxNTFkOTViNDc3ZmJjNDg2YmNiY2VkYyJ9

chore: revert removal of LRO mixin
PiperOrigin-RevId: 476177134

Source-Link: googleapis/googleapis@174b42d

Source-Link: googleapis/googleapis-gen@9b252d4
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiOWIyNTJkNGU1M2IxZGZmYzQwZjc0ZDU3NjU0ZmM0YWIxY2ZjMGY1NCJ9

test: use fully qualified request type name in tests
PiperOrigin-RevId: 475685359

Source-Link: googleapis/googleapis@7a12973

Source-Link: googleapis/googleapis-gen@370c729
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMzcwYzcyOWUyYmEwNjJhMTY3NDQ5YzI3ODgyYmE1ZjM3OWM1YzM0ZCJ9
sofisl pushed a commit that referenced this pull request Nov 18, 2022
sofisl pushed a commit that referenced this pull request Nov 30, 2022
sofisl pushed a commit that referenced this pull request Jan 26, 2023
… the `parameter_values` field (#218)

* feat: Adds support for `google.protobuf.Value` pipeline parameters in the `parameter_values` field

PiperOrigin-RevId: 406492661

Source-Link: googleapis/googleapis@972abb6

Source-Link: googleapis/googleapis-gen@b6774aa
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYjY3NzRhYTNiNjFkMDViZjlmMTBhYTlhZjhkNjIzMTEyNzNkMzVhOSJ9

* 🦉 Updates from OwlBot

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

* 🦉 Updates from OwlBot

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

* 🦉 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>
Co-authored-by: Takashi Matsuo <tmatsuo@google.com>
sofisl pushed a commit that referenced this pull request Jan 26, 2023
🤖 I have created a release \*beep\* \*boop\*
---
## [1.13.0](https://www.github.com/googleapis/nodejs-ai-platform/compare/v1.12.0...v1.13.0) (2021-11-11)


### Features

* Adds support for `google.protobuf.Value` pipeline parameters in the `parameter_values` field ([#218](https://www.github.com/googleapis/nodejs-ai-platform/issues/218)) ([d05a598](https://www.github.com/googleapis/nodejs-ai-platform/commit/d05a598d095ea89cb6a0f385c2f82e9a8224b21f))
---


This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

datastore: Support commit mutation methods on top level of dataset
5 participants