Pavel Vlasov
Pavel Vlasov

Reputation: 4341

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

I need to know when my app's data store was 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?

Upvotes: 0

Views: 494

Answers (2)

Drew Sears
Drew Sears

Reputation: 12838

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.

Upvotes: 1

sje397
sje397

Reputation: 41862

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

Upvotes: 2

Related Questions