gql

GQL query to effectively span entity relationships

Deadly 提交于 2019-12-08 11:20:46
问题 I'm in a situation where I need to span Google App Engine entity relationships in a query like in the Django database model. I'm using ListProperty s for one-to-many relationships, like so: class Foo(db.Model): bars = db.ListProperty(db.Key) class Bar(db.Model): eggs = db.ListProperty(db.Key) And I'd like to perform a query that does the following: # Foo.filter('bars.eggs =', target_egg) [foo for egg in eggs if egg == target_egg for eggs in bar.eggs for bar in foo.bars for foo in Foo.all()]

Need to order by properties in the reference property, any good solution?

对着背影说爱祢 提交于 2019-12-07 15:36:09
问题 Say I have 2 kind: class Account(db.Model): name = db.StringProperty() create_time = db.DataTimeProperty() last_login = db.DateTimeProperty() last_update = db.DataTimeProperty() class Relationship(db.Model) owner = db.ReferenceProperty(Account) target = db.ReferenceProperty(Account) type = db.IntegerProperty() I want to get the equivalence of following query: SELECT target FROM Relationship WHERE owner = :key AND type = :type ORDERBY target.last_login DESC How to do that? reference: http:/

HAS ANCESTOR and HAS DESCENDANT clauses in google cloud datastore

和自甴很熟 提交于 2019-12-07 12:56:11
问题 I'm studying the Google Cloud Datastore GQL grammar - specifically the HAS ANCESTOR and HAS DESCENDANT comparison operators. Giving the following Person entities: Amy Fred, parent = Amy Laura, parent = Amy Paul Agnes ... Would the GQL queries below produce the same output? SELECT * FROM Person WHERE key_name='Fred' HAS ANCESTOR KEY('Person', 'Amy') SELECT * FROM Person WHERE KEY('Person', 'Amy') HAS DESCENDANT key_name='Fred' If so, I don't understand the existence of HAS DESCENDANT clause.

Need to order by properties in the reference property, any good solution?

笑着哭i 提交于 2019-12-06 03:32:28
Say I have 2 kind: class Account(db.Model): name = db.StringProperty() create_time = db.DataTimeProperty() last_login = db.DateTimeProperty() last_update = db.DataTimeProperty() class Relationship(db.Model) owner = db.ReferenceProperty(Account) target = db.ReferenceProperty(Account) type = db.IntegerProperty() I want to get the equivalence of following query: SELECT target FROM Relationship WHERE owner = :key AND type = :type ORDERBY target.last_login DESC How to do that? reference: http://www.mail-archive.com/google-appengine@googlegroups.com/msg15878.html There's no equivalent for that query

HAS ANCESTOR and HAS DESCENDANT clauses in google cloud datastore

こ雲淡風輕ζ 提交于 2019-12-06 02:10:52
I'm studying the Google Cloud Datastore GQL grammar - specifically the HAS ANCESTOR and HAS DESCENDANT comparison operators. Giving the following Person entities: Amy Fred, parent = Amy Laura, parent = Amy Paul Agnes ... Would the GQL queries below produce the same output? SELECT * FROM Person WHERE key_name='Fred' HAS ANCESTOR KEY('Person', 'Amy') SELECT * FROM Person WHERE KEY('Person', 'Amy') HAS DESCENDANT key_name='Fred' If so, I don't understand the existence of HAS DESCENDANT clause. Thanks in advance! Alfred Fuller These two GQL queries should produce identical results: SELECT * FROM

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

Build a GQL query (for Google App Engine) that has a condition on ReferenceProperty

匆匆过客 提交于 2019-12-05 00:17:46
问题 Say I have the following model: class Schedule(db.Model): tripCode = db.StringProperty(required=True) station = db.ReferenceProperty(Station, required=True) arrivalTime = db.TimeProperty(required=True) departureTime = db.TimeProperty(required=True) And let's say I have a Station object stored in the var foo . How do I assemble a GQL query that returns all Schedule objects with a reference to the Station object referenced by foo ? This is my best (albeit incorrect ) attempt to form such a

App Engine Datastore Viewer, how to show count of records using GQL?

大憨熊 提交于 2019-12-04 23:51:24
I would think this would be easy for an SQL-alike! What I want is the GQL equivalent of: select count(*) from foo; and to get back an answer something similar to: 1972 records. And I want to do this in GQL from the "command line" in the web-based DataStore viewer. (You know, the one that shows 20 at a time and lets me see "next 20") Anyway -- I'm sure it's brain-dead easy, I just can't seem to find the correct syntax. Any help would be appreciated. Thanks! JJ Geewax As it's stated in other questions , it looks like there is no count aggregate function in GQL. The GQL Reference also doesn't say

What's your experience developing on Google App Engine?

你。 提交于 2019-12-04 05:09:33
Is GQL easy to learn for someone who knows SQL? How is Django/Python? Does App Engine really make scaling easy? Is there any built-in protection against "GQL Injections"? And so on... I'd love to hear the not-so-obvious ups and downs of using app engine. Cheers! maetl The most glaring and frustrating issue is the datastore api, which looks great and is very well thought out and easy to work with if you are used to SQL, but has a 1000 row limit across all query resultsets, and you can't access counts or offsets beyond that. I've run into weirder issues, with not actually being able to add or

Search a string beginning with a prefix in Google App Engine Datastore

橙三吉。 提交于 2019-12-04 03:52:57
问题 I want to search all entities whose name starts with a specific string, is this possible in Datastore? I've tried this: q = datastore.NewQuery("Places").Filter("Name > ", "a") But it doesn't work. If this is not possible, what alternative solution can you suggest to me? BigQuery? BigTable or other services on App Engine? 回答1: This is something that is possible, but with a combination of 2 inequality filters. Let's say you want to list Places that have the "li" prefix. This can be described