开发者

Placement of sorted entry in Google App Engine Datastore

I'd like to determine what place a particular entry is in, but the appropriate GQL query is escaping me. Ideally I'd like to know the following details, which seem like they should be known by the Datastore. I just can't seem to figure how to determine it. Can someone help?

  • the placement of a particular entry (in a given sorting, i.e. by开发者_JAVA技巧 a particular property)
  • the total number of entries that exist (w/o retrieving them, just the count)
  • the next entry in the list (I figure as long as I can get the placement, I can make the right query to get the next one by simply getting 2 and taking the latter)

Can someone help?


If you're using Python, check out the google-app-engine-ranklist project, which implements a rank list in the App Engine datastore.


GQL is very limited, and really only exists to give people stuck in an SQL mindset a slightly easier transition to using the App Engine datastore. You can't do any of the things you want to do with GQL syntax.

Assuming you're using python, the second can be done by calling the .count() method of a db.Query or db.GqlQuery object, with the caveat that you must specify the maximum number to count as the parameter to count(), and that this maximum cannot be larger than 1000.

You can't find a particular entry in the result set without fetching all of them and looking for it. The last then becomes trivial, since you've already been fetching all of the entities and you just need to fetch the next one.

None of this is going to be efficient; the datastore isn't designed to do this sort of stuff.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜