Tables
Store records like orders, signups and tickets. Insert, update, list and find rows with no schema to manage.
import { table } from 'wisp';
const orders = table('orders');
const order = await orders.insert({ customer: 'ada@example.com', total: 42, status: 'open' });
const open = await orders.find({ status: 'open' }, { orderBy: 'total', desc: true });
await orders.update(order.id, { status: 'paid' });from wisp import table
orders = table("orders")
order = orders.insert({"customer": "ada@example.com", "total": 42, "status": "open"})
open_orders = orders.find({"status": "open"}, order_by="total", desc=True)
orders.update(order["id"], {"status": "paid"})Tables are created on first write. Names use lowercase letters, digits and _.
#Rows
Rows are JSON objects up to 256 KB. insert adds:
id— time-ordered, so rows list in the order they were created.createdAtandupdatedAt— ISO timestamps.
Use put(id, row) to choose your own id (for example a customer's email), creating or replacing the row.
#Methods
| Method | Returns |
|---|---|
insert(row) | The row with id, createdAt, updatedAt |
put(id, row) | The row, created or replaced |
get(id) | The row, or null / None |
update(id, patch) | The merged row, or null if missing |
delete(id) | — |
list({ limit, cursor }) | { rows, cursor } in insertion order |
find(where, { limit, orderBy, desc }) | Matching rows |
count(where) | Number of matching rows |
where is an object of fields to match ({ status: 'open' }) or a function that returns true for rows to keep. Full signatures: table reference.
#Size and performance
find and count scan the table, up to 10,000 rows. That's fine for typical app data. For bigger datasets or relational queries, use an external database.
update isn't atomic. For counters, use kv.incr.
#In the console
Storage → Tables lists each table and its rows, newest first. Delete individual rows or a whole table there.