def __str__(self):
return f'{self.name} (#{self.id})'
-
-
-
-
# May get used later...
#class PurchaseRecord(SQLModel, table=True):
# id: int | None = Field(default=None, primary_key=True)
pass # Already assigned
return ['Success']
+
+ def purchase_items(self, item_ids):
+ results = []
+ with Session(self.engine) as session:
+ for item_id in item_ids.split(' '):
+ item = session.exec(_get_with_id(Item, item_id)).first()
+ if item:
+ item.purchase_date = dt.today()
+ results.append(str(item))
+ session.commit()
+ return results
+
def purchase_item(self, item_id):
with Session(self.engine) as session:
item = session.exec(_get_with_id(Item, item_id)).first()