googleapis / nodejs-datastore

Node.js client for Google Cloud Datastore: a highly-scalable NoSQL database for your web and mobile applications.
https://cloud.google.com/datastore/
Apache License 2.0
215 stars 102 forks source link

Support retrieving and editing excludeFromIndexes (parity with other client libraries) #1111

Open calsmith opened 1 year ago

calsmith commented 1 year ago

Is your feature request related to a problem? Please describe. There is no way to get/set which fields of an entity are indexed after initial entity creation.

Use case: 1) Retrieve an entity 2) Add a new field to the entity 3) Exclude the new field from being indexed

Unlike the other client libraries, there is no way to achieve this with Node JS.

Describe the solution you'd like Here's example code from the PHP Datastore library which easily enables this use case:

$ds = Datastore::get();
$entity = $ds->lookup($ds->key(...));
$entity["newField"] = 123;
$unindexedFields = $entity->excludedProperties(); // Get the unindexed fields.
$unindexedFields[] = "newField"; // Prevent the new field from being indexed.
$entity->setExcludeFromIndexes($unindexedFields);
$ds->update($entity);

Describe alternatives you've considered Without this functionality, we cannot use Node JS or this library for our project.

Additional context Related requests from other customers: https://github.com/googleapis/nodejs-datastore/issues/914 https://github.com/googleapis/nodejs-datastore/issues/935

danieljbruce commented 1 year ago

To support this feature we should write code to create and delete indexes. The following link shows this is not supported yet.

https://github.com/googleapis/nodejs-datastore/blob/cd59c718ebe6711603b08b3ba2677e5a984bc7e3/src/index-class.ts#L150-L151

bogdan-nourescu commented 2 months ago

I have encountered the same problem as described in the issue #914 I tried to use datastore.merge to add a single property to the entity, but because the excludeFromIndexesresets to all properties indexed and because i have a very large string (in java it was Text) stored, i get an error. So what i have to do, is merge, but provide a full list of excludeFromIndexesso the merge works as expected. Is there any timeline for this to get fixed?