import asyncio

from pydynox import AutoGenerate, Model, ModelConfig
from pydynox.attributes import NumberAttribute, StringAttribute


class Order(Model):
    model_config = ModelConfig(table="orders")

    pk = StringAttribute(partition_key=True, default=AutoGenerate.ULID)
    sk = StringAttribute(sort_key=True)
    total = NumberAttribute()


async def main():
    # Create order without providing pk
    order = Order(sk="ORDER#DETAILS", total=99.99)
    print(order.pk)  # None

    await order.save()
    print(order.pk)  # "01ARZ3NDEKTSV4RRFFQ69G5FAV" (generated ULID)


asyncio.run(main())
