← Capabilities

Core improvement

Lists can be smaller, faster, and safer

Collection reads now cover projections, eager relationships, caching, tenant-safe counts, and polymorphic hydration with clearer contracts.

list()
WhereOrderSelectIncludeCache
Choose compact projected rows or fully hydrated objects intentionally.

Projection avoids unnecessary hydration

list({ select }) validates logical s-m-r-t field names, maps them to database columns, blocks sensitive and permission-gated fields, and returns precisely typed plain rows.

list-open-tasks.ts
typescript
const rows = await tasks.list({
  select: ['id', 'title', 'accountId'] as const,
  where: { status: 'open' },
  orderBy: 'created_at DESC',
  limit: 50
});

// Array<{ id; title; accountId }>, not Task[]

Hydrated lists keep object behavior

Without select, rows become the correct model or STI subtype. include eagerly loads named relationships in batches to avoid N+1 work. Projection and include are intentionally mutually exclusive.

Read caching is explicit

Models or individual list/get calls can opt into TTL caching, including cross-process storage. Writes invalidate affected entries. count always goes to the database and now runs the same tenant interceptors as list.