google-cloud-datastore

Google App Engine and SQL LIKE

时光怂恿深爱的人放手 提交于 2019-12-08 08:09:42
问题 Is there any way to query GAE datastore with filter similar to SQL LIKE statement? For example, if a class has a string field, and I want to find all classes that have some specific keyword in that string, how can I do that? It looks like JDOQL's matches() don't work... Am I missing something? Any comments, links or code fragments are welcome 回答1: As the GAE/J docs say, BigTable doesn't have such native support. You can use JDOQL String.matches for "something%" (i.e startsWith). That's all

Modeling a Friend relationship in GAE

北战南征 提交于 2019-12-08 07:52:41
问题 I am working with GAE and have a user table. Now I want to model friend relationships between users. I am thinking of having 3 properties user1 , user2 and request_status , but the problem is in querying to find a particular user's friends. Since GAE does not allow OR filtering, I have to merge two queries. Clearly that is very inefficient. This is just one problem with my approach. If someone could suggest a solution that lets me keep track of all friend requests as well as the friendship,

Google App Engine Development Server DatabaseError('database disk image is malformed',)

試著忘記壹切 提交于 2019-12-08 07:51:35
问题 I'm trying to run my Google App Engine App with the local Development Server I'm getting this error: DatabaseError('database disk image is malformed',) I think the database files are corrupt. I followed this Stackoverflow post. I tried removing the temporary files at /mytemporarydir/appengine.myproject.myuser but I'm still having the problem. I also tried run the server with option --storage_path=... . It could run (with empty datastore) but I needed sudo access and the database is not saved

Incremental IDs on Objectify

荒凉一梦 提交于 2019-12-08 07:24:45
问题 Since upgrading to GAE 1.8, I'm getting scattered ids when annotating with @Id in Objectify: @Id private Long id; Even though I understand the need for scattered ids in terms of avoiding hotspots on the cloud platform, is there a way in Objectify to get the old incremental ids back? Having to display a hexatridecimal value (like 1DZENH6BSOW) in the UI to avoid that massive generated 64bit id just doesn't cut it. I'm happy to have a secondary annotation @IdLegacy working in conjunction with

Pagination with batch queries? Is it possible to batch gets from the datastore and get a cursor?

时光总嘲笑我的痴心妄想 提交于 2019-12-08 07:12:40
问题 I am currently requesting 20 entries from the datastore, return these to the user with a cursor and in case the user is asking for more entries use the cursor as a new start and ask for the next 20 entries. The code looks something like q := datastore.NewQuery("Item"). Limit(limit) if cursor, err := datastore.DecodeCursor(cursor); err == nil { q = q.Start(cursor) } var is []Item t := q.Run(c) for { var i Item _, err := t.Next(&i) if err == datastore.Done { break } is = append(is, i) } In case

Java datastore write performance: Objectify vs. JPA

梦想与她 提交于 2019-12-08 07:06:26
问题 I ran two five minute long simple benchmarks against the datastore. One used the JPA implementation on top of Datanucleus provided by Google and the other used Objectify for persistence. Each request created 10 new indexed entities with the same 9 fields, each using another datatype. To avoid any effects by the network connection the benchmark returned the timespan between the start and the end of 10 writes. AVG Median 10% 90% 99% JPA 76.5 76 53 98 114 Objectify 41.1 40 39 43 57 Objectify TX

ndb get & get_or_insert how to use ? (alway raise Exception)

此生再无相见时 提交于 2019-12-08 06:46:09
问题 I write code as below from google.appengine.ext import ndb __metaclass__ = type class UserSession(ndb.Model): session = ndb.BlobProperty() class KV: @staticmethod def get(id): r = ndb.Key(UserSession, int(id)).get() if r: return r.session @staticmethod def set(id, value): return UserSession.get_or_insert(int(id), session=value) @staticmethod def delete(id): ndb.Key(UserSession, int(id)).delete() where I write id = 1 key = ndb.Key(UserSession, int(id)) UserSession.get_or_insert(key, session=1)

AppEngine bulk loader and automatically created property values

烂漫一生 提交于 2019-12-08 06:45:35
问题 In my model I have a property: created = db.DateTimeProperty(required=True, auto_now_add=True) When an object of this type is created in the datastore, the created property is automatically populated. When I use the bulk loader tool with a table which does not have this field, the field is not automatically populated when I upload to AppEngine, at which time new objects are created. How can I make it set the created time on new objects uploaded from the bulk loader? 回答1: Add something like

Model design pattern for google app engine

早过忘川 提交于 2019-12-08 06:42:59
问题 I am building an app on google app engine which has three different kind of Users(ABC,LMN,XYZ). This is how my model looks like User(db.Model): email = db.EmailProperty() username = db.StringProperty() password = db.StringProperty() role = db.IntegerProperty() ## role = 1 for ABC;2 for LMN;3 for XYZ ABC(User): name = db.StringProperty() isSuperHero = db.BooleanProperty() LMN(User): nickname = db.StrngProperty() profession = db.StringProperty() # some other random property XYZ(User):

Storing the Cursor for App Engine Pagination

喜欢而已 提交于 2019-12-08 06:35:03
问题 I'm trying to implement pagination using App Engine's RPC and GWT (it's an app engine connected project). How can I pass both the query results and the web-safe cursor object to the GWT client from the RPC? I've seen examples using a servlet but I want to know how to do it without a servelt. I've considered caching the cursor on the server using memcache but I'm not sure if that's appropriate or what should be used as the key (session identifier I would assume, but I'm not sure how those are