how are u doing?
I've been developing some software using the classical mapping from SQLAlchemy and I want to know how can I map a database value to my own value object class.
For example, I have a Wallet class that has a Money attribute that is a value object.
domain
class Money(Decimal):
# logic here
class Wallet:
# other attributes
balance: Money
mapper
wallet_table = Table(
'wallet',
metadata,
Column('id', UUIDType, primary_key=True),
Column('balance', Numeric, nullable=False)
)
wallet_mapper = mapper(Wallet, wallet_table)
How do I tell SQLAlchemy that when querying for this data on the database it should return balance as a Money?