English 中文(简体)
是否有一种(合理的)办法来检查是否存在实体?
原标题:Is there a (cheap) way to check if a entity exists?

我有一些关键之处,我想知道的唯一一点是,在数据库中是否有一个相应的实体。 目前我做的是:

entities = db.get(keys)
for entity in entities:
     if entity:
           # some stuff
     else:
           # some other stuff

在这项工作中,我只需要一个 b子,而不是一个 en子。 是否有办法使这一比法更为便宜?

问题回答

比较你现在利用只限钥匙对钥匙进行单小时查询的速度。 如果有一个明确的赢家,就只处理钥匙,因为成本较低。





相关问题
How to make logging.debug work on Appengine?

I m having a tough time getting the logging on Appengine working. the statement import logging is flagged as an unrecognized import in my PyDev Appengine project. I suspected that this was just an ...

gqlQuery returns object, want list of keys

Is there a way to convert the GqlQuery object to an array of keys, or is there a way to force the query to return an array of keys? For example: items = db.GqlQuery("SELECT __key__ FROM Items") ...

Integrating Google AppEngine with a Thick Client

I want to make a multi-user client-server solution with Java Swing thick client as a front-end and Google AppEngine (Java one) as a back-end. The problem is that GAE provides only web-based forms for ...

sorl.thumbnail : thumbnail is not a valid tag library?

I am trying to install sorl.thumbnail but am getting the following error message: thumbnail is not a valid tag library: Could not load template library from django.templatetags.thumbnail, No module ...

热门标签