- Improved support for foreign model updates, .save() will invoke creation of foreign objects if not existing,
- Added support for Arrays of Foreign References where a single field in a DataBaseModel may contain a list of other DataBaseModel objects
from uuid import uuid4
from datetime import datetime
from typing import List, Optional
from pydbantic import DataBaseModel, PrimaryKey
def time_now():
return datetime.now().isoformat()
def get_uuid4():
return str(uuid4())
class Coordinate(DataBaseModel):
time: str = PrimaryKey(default=time_now)
latitude: float
longitude: float
class Journey(DataBaseModel):
trip_id: str = PrimaryKey(default=get_uuid4)
waypoints: List[Optional[Coordinate]]