open-law/app/models/utils.py

24 lines
538 B
Python
Raw Normal View History

2023-04-21 12:58:47 +00:00
from datetime import datetime
2023-04-20 13:10:16 +00:00
from app import db
class ModelMixin(object):
def save(self, commit=True):
# Save this model to the database.
db.session.add(self)
if commit:
db.session.commit()
return self
2023-04-21 12:58:47 +00:00
class BaseModel(db.Model, ModelMixin):
__abstract__ = True
id = db.Column(db.Integer, primary_key=True)
created_at = db.Column(db.DateTime, default=datetime.now)
is_deleted = db.Column(db.Boolean, default=False)
2023-04-20 13:10:16 +00:00
# Add your own utility classes and functions here.