Skip to content

Instantly share code, notes, and snippets.

@dangayle
Created May 29, 2020 18:18
Show Gist options
  • Save dangayle/0f2d10111668b4757a11784ba56ddd94 to your computer and use it in GitHub Desktop.
Save dangayle/0f2d10111668b4757a11784ba56ddd94 to your computer and use it in GitHub Desktop.
from app import db
from sqlalchemy import func, types
from sqlalchemy.dialects import postgresql
class JSONCache(db.Model):
id = db.Column(db.Integer, primary_key=True)
key = db.Column(db.String, nullable=False, index=True)
data = db.Column(postgresql.JSONB, nullable=False)
timestamp = db.Column(types.TIMESTAMP, server_default=func.now(), nullable=False)
__mapper_args__ = {"order_by": timestamp.desc()}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment