SeleID

SeleBase

Examples

Overview · SQL console · Limits · Migrations · Errors · Examples

JavaScript

const res = await fetch(`${BASE}/v1/databases/main/query`, {
  method: 'POST',
  headers: { authorization: `Bearer ${process.env.SELEBASE_KEY}`, 'content-type': 'application/json' },
  body: JSON.stringify({ sql: 'SELECT id, body FROM notes WHERE id > ? ORDER BY id LIMIT 50', params: [0] }),
});
if (!res.ok) throw new Error((await res.json()).error);
const { rows, truncated } = await res.json();

sql

-- pagination
SELECT id, body FROM notes WHERE id > ? ORDER BY id LIMIT 100;
-- count without scanning more than needed: add an index on filtered columns
CREATE INDEX IF NOT EXISTS notes_created ON notes (created_at);

Tips: use bound parameters, add indexes for filters (each scanned row counts as a row read), and use a read key in services that only query.

Last updated 2026-11-12Suggest an editReport a problem with this page