Reylo infers type information from SQL queries, against a live database.
select u.id, u.name, count(p.id)::int as post_count from users u left join posts p on p.user_id = u.id where u.id = :id::int group by u.id
Parameters, columns, nullability, cardinality and nested JSON shapes, from your database's own analysis of each query.
update users set name = :name where id = :id
{ name: string; id: number }
void
select u.name, p.title from users u left join posts p on p.user_id = u.id where u.id = :user_id::int
{ user_id: number }
{ name: string; title: string | null }[]
select u.name, coalesce(u.email, '') as email, exists (select 1 from posts p where p.user_id = u.id) as has_posts from users u where u.role = :role
{ role: "admin" | "member" }
{ name: string; email: string; has_posts: boolean }[]
select id, title from posts where user_id = coalesce(:user_id::nullable(int), user_id)
{ user_id?: number | null }
{ id: number; title: string }[]
select id, name from users where email = :email::text
{ email: string }
{ id: number; name: string } | null
select count(*)::int as posts from posts where user_id = :user_id::int
{ user_id: number }
{ posts: number }
select id, title, row_number() over ( partition by user_id order by published_at ) as n, lag(title) over (order by id) as prev from posts
void
{ id: number; title: string; n: bigint; prev: string | null }[]
select u.name, p.title, p.published_at from users u left join lateral ( select title, published_at from posts where user_id = u.id order by published_at desc nulls last limit 1 ) p on true
void
{ name: string; title: string | null; published_at: string | null; }[]
insert into users (name) values (:name::text) returning id
{ name: string }
{ id: number }
select id, kind from events order by id desc limit :limit::int
{ limit: number }
{ id: number; kind: "click" | "key" }[]
select u.name, jsonb_agg(jsonb_build_object('id', p.id, 'title', p.title)) as posts from users u join posts p on p.user_id = u.id where p.published_at > :since group by u.id
{ since: string }
{ name: string; posts: { id: number; title: string }[] }[]
select id, payload from events where id = :id::int
{ id: number }
{ id: number; payload: { x: number; y: number } } | null
select id, payload from events where id = :id::int
{ id: number }
{ id: number; payload: | { kind: "click"; x: number; y: number } | { kind: "key"; code: string }; } | null
Any syntax, function or operator your database supports, from window functions to JSON aggregation and returning clauses.
Parameters, columns, nullability and cardinality come from the database's own analysis of each query. There is nothing to declare by hand.
A misspelled column is a type error at its line and column, and so is a wrong argument to .run().
A query and its types are one file. An agent edits the SQL, and the types follow, with nothing else to update.
Each in its own dialect, on Neon, Supabase, PlanetScale, Cloudflare D1, Turso and more.
Runs on pg, postgres.js, Bun.sql, Neon, mysql2, mariadb, PlanetScale, better-sqlite3, node:sqlite, libSQL, Cloudflare D1 and more, or through Drizzle and Knex.