link tables
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
from datetime import datetime, timezone, timedelta
|
||||
from itertools import product
|
||||
from app.extensions import db
|
||||
from app.models.customer import Customer
|
||||
from app.models.account import Account
|
||||
# from app.models.customer import Customer
|
||||
# from app.models.account import Account
|
||||
from sqlalchemy.exc import IntegrityError
|
||||
from sqlalchemy.orm import relationship
|
||||
from dateutil.relativedelta import relativedelta
|
||||
@@ -33,6 +33,13 @@ class MembersProducts(db.Model):
|
||||
added = db.Column(db.DateTime(timezone=True), server_default=func.now())
|
||||
updated = db.Column(db.DateTime(timezone=True), server_default=func.now(), onupdate=func.now())
|
||||
|
||||
products = relationship(
|
||||
"Products",
|
||||
primaryjoin="Products.product_id == MembersProducts.product_id",
|
||||
foreign_keys=[product_id],
|
||||
back_populates="members_products",
|
||||
)
|
||||
|
||||
|
||||
@classmethod
|
||||
def get_member_productlist_by_member_id(cls, member_id):
|
||||
@@ -87,6 +94,8 @@ class MembersProducts(db.Model):
|
||||
return {
|
||||
'id': self.id,
|
||||
'uid': self.uid,
|
||||
'name': self.name,
|
||||
'description': self.description,
|
||||
'product_id': self.product_id,
|
||||
'internal_url': self.internal_url,
|
||||
'external_url': self.external_url,
|
||||
|
||||
Reference in New Issue
Block a user