~/docs/backends/data

Dashboard

Backends

Data

Query your Postgres tables from the client, with row-level security and generated types.

Updated

2026-12-02

Source

apps/web/docs/backends/data.mdx

ts

const { data: todos } = await phz
  .from('todos')
  .select('id, title, done')
  .eq('done', false)
  .order('created_at', { ascending: false });

await phz.from('todos').insert({ title: 'Ship it' });
await phz.from('todos').update({ done: true }).eq('id', id);
await phz.rpc('my_function', { arg: 1 });

Row-level security applies to every query made with the publishable key and a signed-in user's session.

Types

terminal

npx @pherwerz/cloud gen types --db-url "$DATABASE_URL" --out database.types.ts

ts

import type { Database } from './database.types';

export const phz = createClient<Database>(url, publishableKey);

Table names, columns, filters, select results and insert and update payloads are then all type-checked.