开发者

The easiest way to know App Engine datastore's last change time

I need to know when my app's data store was 开发者_StackOverflow中文版last updated.

Surely I could find and patch every line of code where queries INSERT, UPDATE and DELETE are used but may be there is such official capability in datastore?


You can use a 'database service hook' to execute your own bit of code whenever the database is written to.

See http://code.google.com/appengine/articles/hooks.html


I would advise against trying to accomplish this with an RPC hook. RPC hooks are neat, but they plug into relatively low-level components of the datastore stack. It's preferable to work with the high-level abstractions unless there's a good reason not to.

Why not just attach an update timestamp to your models?

class BaseModel(db.Model):
  updated_at = db.DateTimeProperty(auto_now=True)

class MyModel(BaseModel):
  name = db.StringProperty()

class OtherModel(BaseModel):
  total = db.IntegerProperty()

Every model that inherits from BaseModel will automatically track an update timestamp.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜