Update ORM Mappings

This commit is contained in:
2022-07-12 07:39:15 -07:00
parent 4102eecd22
commit edd129e532

View File

@@ -27,20 +27,30 @@ __all__ = ('init_orm', )
def init_orm():
"""Initialize the Sigl ORM."""
# # Access Keys
# db.mapper(AccessKey, access_keys, properties={
# 'tokens': db.relationship(
# AccessToken,
# backref='accessKey',
# cascade='all, delete-orphan',
# )
# })
# Access Keys
db.mapper(AccessKey, access_keys, properties={
'tokens': db.relationship(
AccessToken,
back_populates='accessKey',
cascade='all, delete-orphan',
)
})
# # Access Tokens
# db.mapper(AccessToken, access_tokens)
# Access Tokens
db.mapper(AccessToken, access_tokens, properties={
'accessKey': db.relationship(
AccessKey,
back_populates='tokens',
)
})
# # List Entries
# db.mapper(ListEntry, list_entries)
db.mapper(ListEntry, list_entries, properties={
'shoppingList': db.relationship(
ShoppingList,
back_populates='entries',
)
})
# Products
db.mapper(Product, products, properties={
@@ -49,11 +59,6 @@ def init_orm():
back_populates='product',
cascade='all, delete-orphan',
),
# 'shoppingLists': db.relationship(
# ShoppingList,
# backref='product',
# cascade='all, delete-orphan',
# ),
})
# Product Locations
@@ -64,11 +69,11 @@ def init_orm():
)
})
# # Shopping Lists
# db.mapper(ShoppingList, lists, properties={
# 'entries': db.relationship(
# ListEntry,
# backref='shoppingList',
# cascade='all, delete-orphan',
# )
# })
# Shopping Lists
db.mapper(ShoppingList, lists, properties={
'entries': db.relationship(
ListEntry,
back_populates='shoppingList',
cascade='all, delete-orphan',
)
})