0
votes

I am working on a POC (to move part of functionality from relational DB to cloud datastore). I have few questions:

  1. I would need to refresh few "kind" every night as the data comes up from a different data source (via flat files). I read about it, and understood that there is not TRUNCATE kind of functionality in datastore. I believe, only option is to retrieve the keys from the "kind" in a loop and delete entity by entity. And use import functionality to load the new set of data. Is there any better option?
    1. Assume I have a kind called department, and a kind called store. Now, I need a kind called dept-store. So for this parent nodes are department and store. Is there a way to enforce this kind of relationship? From the documentation I see that there can only be one parent.
    2. If i have a child entity in kind1 whose parent is present in kind2, and they are linked together, is there a way to query all the properties present in kind1 and kind2 together? From relational DB perspective, it is like equi-join with "SELECT *". I am looking for an equivalent functionality in datastore.
1

1 Answers

0
votes

In order to answer your questions:

  1. There is two ways to delete multiple entities. First, you can use Cloud Dataflow to delete entities in Bulk [1]. Second, once keys are retrieved you can make a batch delete operation by passing the keys to Datastore delete function, you have the usage example here [2]. In order to retrieve the keys you can run keys-only query [3].

  2. In Datastore an entitiy can have only one parent but can have multiple children. But for your use case you may try to have a third kind, dept-store, and assign its properties as the keys of the entities from the department and the store kinds. This solution might need a good understanding of your neeeds for implementation, as Datastore by nature is Non-relational database.

  3. You can lookup multiple entities providing the keys retrieved from kind1 and kind2 with batch operations [2].