// EXECUTOR (server-only): returns a query builder with an eager `.with(...)` // spec. `.with({ books: true })` attaches each author's books as an array on // the row — compiled into ONE SQL roundtrip via the dialect's JSON-aggregation // idiom (postgres jsonb_agg, sqlite json_group_array, mysql JSON_ARRAYAGG, // mssql FOR JSON PATH). The per-branch `limit`/`orderBy` apply PER author. // // `authors` carries `tenant()`, so the runtime scopes the root read to the // caller's tenant automatically. import type { AppContext } from '@voltro/runtime' import { database } from '../database/index' const execute = (_input: Record, _ctx: AppContext) => database.authors.with({ books: { orderBy: [{ column: 'title', direction: 'asc' }], limit: 50 }, }) export default execute