Query on Indexes
Access indexes as attributes on the table instance. The builder automatically resolves the correct sort key for the index.
Query GSI
# Query GSI
pending = (
orders.by_status
.query(status="PENDING")
.where(gte="2025-01-01") # SK is "created_at" (from index definition)
.filter(total__gte=100)
.select("user_id", "total") # validated against index projection
)
# Query another GSI
recent = (
orders.by_date
.query(user_id="usr_123")
.where(between=["2025-01-01", "2025-12-31"])
.scan_forward(False)
.limit(10)
)
Projection Validation
If you .select() attributes not available in the index, dkmio raises InvalidProjectionError immediately:
# This raises InvalidProjectionError because "description" is not
# in by_status's INCLUDE projection (only "total" and "items_count")
orders.by_status.query(status="PENDING").select("description")
tip
dkmio validates projections at query time, not at execution time, so you catch errors immediately instead of silently getting partial data.