Query and insert rows in a Supabase Postgres table using the official @supabase/supabase-js client. Supports column selection, filtering with multiple operators, ordering, and pagination.
Closes #38
| Parameter | Type | Required | Description |
|---|---|---|---|
action |
string |
No | "query" to read rows, "insert" to add a row (default "query") |
table |
string |
Yes | Supabase table name |
columns |
string |
No | Comma-separated columns to select (default "*") |
filters |
array |
No | Filter objects: { column, operator, value } |
order_by |
string |
No | Column to sort results by |
ascending |
boolean |
No | Sort direction (default true) |
limit |
integer |
No | Max rows to return, 1–1000 (default 50) |
offset |
integer |
No | Rows to skip for pagination (default 0) |
row |
object |
For insert | Key-value object to insert |
eq, neq, gt, gte, lt, lte, like, ilike, in
| Variable | Description |
|---|---|
SUPABASE_URL |
Your Supabase project URL (e.g. https://xyzcompany.supabase.co) |
SUPABASE_ANON_KEY |
Your Supabase anonymous (public) API key |
cd tools/supabase_table_query
npm installimport { queryTable } from "./index";
const result = await queryTable("products", {
columns: "id,name,price",
filters: [{ column: "price", operator: "gte", value: 10 }],
order_by: "price",
ascending: false,
limit: 20,
});
console.log(result);import { insertRow } from "./index";
const result = await insertRow("products", {
name: "New Widget",
price: 29.99,
category: "electronics",
});
console.log(result);import { runTool } from "./index";
// Query
const rows = await runTool("query", "users", {
filters: [{ column: "role", operator: "eq", value: "admin" }],
limit: 10,
});
// Insert
const inserted = await runTool("insert", "users", {
row: { name: "Alice", role: "admin" },
});