oRPC
oRPC Recipe
Section titled “oRPC Recipe”UQL queries are plain JSON, so they pass through oRPC procedures without any adapter. There is nothing to install beyond your existing oRPC setup: procedures call the querier pool directly, and oRPC’s type<T>() helper declares the pass-through input type.
import { os, type } from '@orpc/server';import { getQuerierPool } from 'uql-orm';import type { Query, Type } from 'uql-orm/type';import { User } from './shared/models/index.js';
const pool = getQuerierPool();
function entityRouter<E extends object>(entity: Type<E>) { return { findMany: os .input(type<Query<E>>()) .handler(({ input }) => pool.findMany(entity, input)), insertOne: os .input(type<E>((value) => value)) // identity mapper: required when the input type is an open generic .handler(({ input }) => pool.transaction((querier) => querier.insertOne(entity, input))), };}
export const router = { user: entityRouter(User) };On the client, the query object is fully typed end to end:
const users = await client.user.findMany({ $where: { email: { $endsWith: '@domain.com' } }, $limit: 10,});