google-cloud-datastore

GAE Python NDB .put not synchronous on development (but works in production)?

大兔子大兔子 提交于 2019-12-24 10:50:55
问题 The following below should create a Counter model and use (deferred) tasks to increment the counter to 10. Visiting '/' ought to create a single Counter object with count = 10 . This happens in production. In development (localhost) multiple Counter objects are created with the largest being 10: I suspect this is because the put is not synchronous on development (but appears to always be on production). Is there a way to make them synchronous? Code snippet below: class Counter(ndb.Model):

GAE Datastore with GWT, making more friendly/smaller keys

坚强是说给别人听的谎言 提交于 2019-12-24 10:39:40
问题 I am currently working with GWT, GAE and using JPA as my ORM. I have an issue where the keys that GAE is generating are too large reasonably to be used on a mobile device with RequestFactory. The amount of data in a small list is overwhelming due to the size of the ID/KEY when converted to String. I am using String for my key's so that I can handle inheritence. @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Extension(vendorName = "datanucleus", key = "gae.encoded-pk", value = "true"

Unique email in Google Datastore

自作多情 提交于 2019-12-24 10:08:54
问题 I have a User entity containing an Email field. The User entity id is a ULID, because I want to allow users to change their email addresses, but I want to ensure that the email address is unique on both a CREATE and an UPDATE . I am using Datastore transactions. This is a code fragment: ctx := context.Background() k := datastore.NameKey("User", user.ID, nil) _, err := client.RunInTransaction(ctx, func(t *datastore.Transaction) error { // other stuff that needs to be in transaction _, err = t

How to rename a Datastore entity field but be able to retrieve records via old and new property names?

天大地大妈咪最大 提交于 2019-12-24 09:29:02
问题 I have an entity class Foo { public String bar; } I want to rename "bar" to "somethingElse". And was planning on using Objectify's @AlsoLoad annotation to achieve that (I am already using Objectify for persistence). So something like: class Foo { @AlsoLoad("bar") public String somethingElse; } But any queries of the form: final Query<Foo> query = OfyService.ofy().load().type(Foo.class) .filter("somethingElse", "someValue"); Only retrieve entities that have been saved since the rename. Any

Intersection on Google App Engine

蓝咒 提交于 2019-12-24 08:47:38
问题 When a user Facebook Connects to my site, I want to narrow down the list of the user's Facebook friends to just those that have already signed up for my website. So I have two lists A list in code of a user's facebook friends (around 1000) A GAE table of all FB users that have signed up for my site (around 1000) Is the most efficient way to do this to do a single query for the UIDs of all signed up FB users and do the intersection in code? What would be the most efficient way if there were

Google Cloud Datastore unique autogenerated ids

依然范特西╮ 提交于 2019-12-24 08:38:29
问题 I'm using Google Cloud Datastore and using namespaces to partition data. Some kinds are using autogenerated IDs from Cloud Datastore by creating keys like this: var key = Datastore.key([ 'example' ]); This code will generate a key with kind 'example' and Cloud Datastore automatically assign the entity an integer numeric ID. (Source: https://cloud.google.com/datastore/docs/concepts/entities#kinds_and_identifiers) But this "unique" ID is only unique for its namespace. I have seen the same ID in

Relation Index Entities and Projections Query

走远了吗. 提交于 2019-12-24 07:37:35
问题 I am designing google datastore schema for the classic 'User Posts' and 'Tags' questions. This page suggests Relation Index Entities model. Basically it puts searchable tags or keywords as list property in child entity for filtering, and the necessary properties in parent entity. To my understanding, this approach is to reduce serialization overhead at query time. class Post(db.Model): title = db.StringProperty() post_date = db.DateTimeProperty() class Tags(db.Model): tags = db

Gcloud beta emulators data store start error Google/Cloud is not recognized as an internal or external command

眉间皱痕 提交于 2019-12-24 07:16:07
问题 In developing php appengine standard app, I wanted a local development datastore so I ran- gcloud components install cloud-datastore-emulator I also installed google cloud data store globally using composer require google\cloud_datastore After that tried to start the emulator with gcloud beta emulators datastore start --data-dir="C:\Users\Hellen\Desktop\New folder\myDstore" But the command failed with the following output. WARNING: Reusing existing data in [C:\Users\Hellen\Desktop\New folder

Add, Update, Delete from a ndb.KeyProperty() - Google Cloud Datastore NDB

我的未来我决定 提交于 2019-12-24 07:09:26
问题 Here are my many-to-many relationship models: class ModelA(ndb.Model): name = ndb.StringProperty(required=true) model_b = ndb.KeyProperty(kind=ModelB,repeated=True) class ModelB(ndb.Model): name = ndb.StringProperty(required=true) model_a = ndb.KeyProperty(kind=ModelA,repeated=True) My question is, how do I add/update/delete a single (or many) KeyProperty from let's say model_b ? 回答1: I managed to do it like this: pos = ModelA.model_b.index(ndb.Key('ModelB',213)) # Get position from list

NDB Query builder doesn't work as expected

眉间皱痕 提交于 2019-12-24 06:47:19
问题 I have the following query in my application query = cls.query().filter(cls.taskgroup_id == taskgroup_id, cls.availability == True, cls.task_id > min_task_id).order(cls.task_id) query.fetch(1) Above works fine as expected. (Fetches only those entities, which match taskgroup_id, and is available, and task_id > min_task_id) However, when I break query into multiple statements. query = cls.query() query.filter(cls.taskgroup_id == taskgroup_id) query.filter(cls.availability == True) query.filter