# Path: app/main.py



from app.main import db
"""
Goal: simplify the code when interacting with entities

Usage when declaring a model:

import db
class MyEntity(db.Model, CRUDMixin):
    id = db.Column('myID', db.Integer, primary_key=True)
    data = db.Column('myData', db.String(255))

MyTableEntity.create(data="abc")

my = MyTableEntity(data="abc")
db.session.save(my, commit=False)

found = MyTableEntity.get_by_id(1) is not None
"""


class CRUDMixin(object):
    """ Helper class flask-sqlalchemy entities """
    __table_args__ = {'extend_existing': True}


# Path: app/main.py



# Path: app/crud_mixin.py
from app.main import db

"""
Goal: simplify the code when interacting with entities

Usage when declaring a model:

import db
class MyEntity(db.Model, CRUDMixin):
    id = db.Column('myID', db.Integer, primary_key=True)
    data = db.Column('myData', db.String(255))

MyTableEntity.create(data="abc")

my = MyTableEntity(data="abc")
db.session.save(my, commit=False)

found = MyTableEntity.get_by_id(1) is not None
"""


class CRUDMixin(object):
    """ Helper class flask-sqlalchemy entities """
    __table_args__ = {'extend_existing': True}


    id = db.Column(db.Integer, primary_key=True)