google-cloud-datastore

Can you help me understand the nbd Key Class Documentation or rather ancestor relationship?

放肆的年华 提交于 2019-12-12 04:07:11
问题 I am trying to wrap my head 'round gae datastore, but I do not fully understand the documentation for the Key Class / or maybe it is ancestor relationships in general I do not grasp. I think what I want is multiple ancestors. Example: Say I wanted to model our school's annual sponsored run for charity; school kids run rounds around the track and their relatives (=sponsors) donate to charity for each round completed. In my mind, I would create the following kinds: Profile (can be both runner

How to reduce number of requests to the Datastore

大憨熊 提交于 2019-12-12 04:04:29
问题 When running the below with 200 Documents and 1 DocUser the script takes approx 5000ms according to AppStats. The culprint is that there is a request to the datastore for each lockup of the lastEditedBy (datastore_v3.Get) taking 6-51ms each. What I'm trying do is to make something that makes possible to show many entities with several properties where some of them are derived from other entities. There will never be a large number of entities (<5000) and since this is more of an admin

How to remove built-in kinds' names in google datastore using kind queries

喜夏-厌秋 提交于 2019-12-12 03:57:50
问题 I am trying to use google cloud datastore kind query to get a list of kind names as demoed in the Kind queries, query = client.query(kind='__kind__') query.keys_only() kinds = [entity.key.id_or_name for entity in query.fetch()] but the code generates some built-in kind names, e.g. ['_AE_DatastoreAdmin_Operation', '_GAE_MR_TaskPayload', '__Stat_Kind_IsRootEntity__', '__Stat_Kind_NotRootEntity__', '__Stat_Kind__', '__Stat_PropertyName_Kind__', '__Stat_PropertyType_Kind__', '__Stat_PropertyType

GAE datastore design to store “like” mechanism for user's status (like Facebook's “likes”)

雨燕双飞 提交于 2019-12-12 03:26:03
问题 I'm using Google App Engine's datastore and looking for a design solution for "like" functionality for user's status (similair to Facebook "likes") I've gone through the Sharding Counters concepts (https://developers.google.com/appengine/articles/sharding_counters) and found its good and suitable for counting number of likes where you can increment or decrement the count. But I want to store the userId who liked the status. So I tried the same sharding concepts to store userIds but facing the

need to get entity key to delete entity

坚强是说给别人听的谎言 提交于 2019-12-12 03:25:32
问题 I am trying to delete an entity from the Datastore using a link in html. I understand that in order to do this, I need to have the entity's key so that I know which entity to "pair" the delete link with, so to speak. I can't for the life of me figure out how to do this... Here is my html file that shows all of the cars in the database: {% if cars|length > 0 %} {% for c in cars %} <tr> <td>{{ c.make }}</td> <td>{{ c.model }}</td> <td>{{ c.year }}</td> <td> {% for i in c.color %} {{ i }} {%

Ancestor Query Direct Descendants - Google Datastore

荒凉一梦 提交于 2019-12-12 03:19:05
问题 I'm building a catalog application in Google App Engine, using Go, and Google Datastore. I'm using the Ancestor features of the datatore to manage different product categories. Here's an example of some data: Musical Instruments -> Guitars -> Gibson -> Les Paul Musical Instruments -> Guitars -> Fender -> Stratocaster Musical Instruments -> Bass Guitars -> Music Man -> Stingray Musical Instruments is the root entity. When I click it, I expect to see Guitars and Bass Guitars , but instead I see

Buying many products at once from a webshop

╄→尐↘猪︶ㄣ 提交于 2019-12-12 03:18:13
问题 It's quite simple to program just one product to get sold via my payment system (api.payson.se) but buying many products at the same time in various amounts posed trouble for me since it was not implemented and I didn't have a good idea how to do it. Now I have a solution that I just put together which works but the modelling and control flow is kind of very quick and dirty and I wonder whether this is even acceptable or should need a rewrite. The system now behaves so that I can enter the

Random querying for Google App Engine Datastore entities using Java

流过昼夜 提交于 2019-12-12 02:38:45
问题 Let's say I have 100 entities in my datastore. I have sorted my query on basis of a property say "age" using Query q = new Query("EntityTYPE").addSort("age", SortDirection.DESCENDING); I have a variable startPoint from another function which tells me the start point of the result needed. Now that I need to query 10 entities (startPoint to startPoint+10) from the sorted query. Example: If startPoint = 51, I need result entity to have values of 51-61 rows of the sorted query. How can I

appengine datastore change entities property

白昼怎懂夜的黑 提交于 2019-12-12 02:32:04
问题 I would like to change the entity property from String to long. I have seen Nick answering similar problem in Change IntegerProperty to FloatProperty of existing AppEngine DataStore but I am writing in Java and need some code example since I don't know anything about the mapreduce. e.g. we want to change userId from String to Long of this class. I also would like to get advice on my thinking of storing date in long instead of String so that the time information can be consumed readily from

How to find the max value per group in NDB

China☆狼群 提交于 2019-12-12 01:59:30
问题 I'm used python with ndb in my app. How to find the max value per group in NDB? My table user_id | level_number | score --------+--------------+-------------------- 1 | 1 | 15 1 | 1 | 5 1 | 2 | 26 1 | 2 | 30 I want to get max score each level 回答1: From what I can see, the best would be to do a query with a sort order on the score where level_number = 1, then 2, then 3. Since the datastore cannot do computations, you'll need to use the sorting and just keep the highest one, if you don't want