google-cloud-datastore

Why do I get Only ancestor queries are allowed inside transactions error

☆樱花仙子☆ 提交于 2019-12-05 09:19:25
boolean r = ofy().transact(new Work<Boolean>() { @Override public Boolean run() { Visit visit = ofy().load().type(Visit.class) .filter(Visit.USER_ID, userID) .filter(Visit.VENUE_ID, venueID).first().get(); if (visit == null) return false; visit.setLastRequestDate(new Date(timestamp)); ofy().save().entity(visit).now(); return true; } }); and I get java.lang.IllegalArgumentException: Only ancestor queries are allowed inside transactions. for the line with the get() call. why? I'm only querying Visit entity in this transaction. I'm doing this in a transaction, because I want all this to be

gcloud.exceptions.Forbidden: 403 Missing or insufficient permissions

老子叫甜甜 提交于 2019-12-05 08:04:25
I am a new to Google Cloud Platform. I have setup a Google VM Instance. I am facing an authentication issue on Local Machine while running the command: python manage.py makemigrations Can you please suggest some tips/steps to resolve the same ? Error Trace File "/constants.py", line 18, in <module> table_data = datastore_fetch(project_id, entity_kind) File "/datastore_helper.py", line 23, in datastore_fetch results = list(query.fetch()) File "/venv/local/lib/python2.7/site-packages/gcloud/datastore/query.py", line 463, in __iter__ self.next_page() File "/venv/local/lib/python2.7/site-packages

How to model entity relationships in GAEJ?

早过忘川 提交于 2019-12-05 07:46:06
I would like to know -an example is highly appreciated- How to model relationships in Google App Engine for Java? -One to Many -Many to Many I searched allover the web and I found nothing about Java all guides and tutorials are about Python. I understood from this article that in Python the relationships are modeled using ReferenceProperty . However, I found nothing about this class in the Javadoc reference. Furthermore, in this article they discussed the following: there's currently a shortage of tools for Java users, largely due to the relative newness of the Java platform for App Engine.

What is a good pattern for inexact queries in the Google App Engine Datastore?

≯℡__Kan透↙ 提交于 2019-12-05 06:20:31
问题 The Google App Engine Datastore querying language (gql) does not offer inexact operators like "LIKE" or even case insensitivity. One can get around the case sensitive issue by storing a lower-case version of a field. But what if I want to search for a person but I'm not sure of the spelling of the name? Is there an accepted pattern for dealing with this scenario? 回答1: Quoting from the documentation: Tip: Query filters do not have an explicit way to match just part of a string value, but you

Datastore on flex nodejs appengine stopped working - bad gateway 502

假如想象 提交于 2019-12-05 05:42:56
问题 After making some updates to an app I'm working on, I pushed the app up via gcloud app deploy --version dev and everything seemed to push just fine, but upon further inspection, any of my calls (get or post) that use the @google-cloud/datastore package fail with Bad Gateway 502 - nginx error. I've put in console.logs everywhere and they never get past the line before any datastore.whatever() calls. tested with .save, .runQuery, and .update. Weirder still, i can access the datastore just fine

Inequality Filter in AppEngine Datastore

那年仲夏 提交于 2019-12-05 05:14:23
I understand that Google AppEngine supports only one inequality filter per query. What are the workaround on this limitation? Are there any solution that will provide similar effect? Actually GAE supports multiple inequality filters as long as they are on the same property . The workarounds to this limitation are data-specific, e.g. it depends how your data is structured and how you want to query it. For example, for geo searching, as @Dan Holevoet mentioned, there are various geo-hashing algorithms. Basically all such algorithms involve combining multiple properties into one and at the same

Google datastore - querying on key values

这一生的挚爱 提交于 2019-12-05 05:09:46
I have a EntityKind SuggestedInterest. When I populate that with a key "GrpId" and property "suggestedint". Now, I need the "suggestedint" value for a requested "GrpId" So, I write the query as: String findSuggestedInterest(String grpId) { DatastoreService datastore = DatastoreServiceFactory.getDatastoreService(); Filter filter = new FilterPredicate(Entity.KEY_RESERVED_PROPERTY,FilterOperator.EQUAL,grpId); Query q0 = new Query("SuggestedInterest").setFilter(filter); PreparedQuery pq0 = datastore.prepare(q0); Entity result = pq0.asSingleEntity(); return result.getProperty("suggestedint")

GAE Implications of NDB hierarchy and entity groups

邮差的信 提交于 2019-12-05 04:32:34
问题 I'm trying to better understand the implications of the deep hierarchy described in the GAE NDB docs "For example, a revision of a message that "belongs to" an owner, might have a key that looks like" rev_key = ndb.Key('Account', 'Sandy', 'Message', 'greeting', 'Revision', '2') I interpret this to mean that if I do Revision(parent=rev_key).put() then I will have an entity group at the Revision=2 level meaning ancestor queries where ancestor=rev_key will have strong consistency and writes

How do you NOT automatically dereference a db.ReferenceProperty in Google App Engine?

╄→尐↘猪︶ㄣ 提交于 2019-12-05 04:20:23
问题 Suppose I have class Foo(db.Model): bar = db.ReferenceProperty(Bar) foo = Foo.all().get() Is there a way for me to do foo.bar without a query being made to Datastore? The docs say that foo.bar will be an instance of Key , so I would expect to be able to do foo.bar.id() and be able to get the id of the Bar that's associated with foo , but it doesn't seem to work that way. PS: The part of the docs I'm referring to can be found here: http://code.google.com/appengine/docs/python/datastore

GAE development server keep full text search indexes after restart?

爱⌒轻易说出口 提交于 2019-12-05 03:56:06
Is there anyway of forcing the GAE dev server to keep full text search indexes after restart? I am finding that the index is lost whenever the dev server is restarted. I am already using a static datastore path when I launch the dev server (the --datastore_path option). This functionality was added a few releases ago (in either 1.7.1 or 1.7.2, I think). If you're using an SDK from the last few months it should be working. You can try explicitly setting the --search_indexes_path flag on dev_appserver.py ; it's possible that the default location ( /tmp/ ) isn't writable. Could you post the first