Promises as fields
user.name is a Promise
Entity fields are Promises. React `use()`-native. Aggregate queries that re-run — and re-render only the leaves whose data moved.
// orm.ts
import { Orm } from "sql-reactive-orm";
import { SqlJsDriver } from "sql-reactive-orm/drivers/sqljs";
import wasmUrl from "sql.js/dist/sql-wasm.wasm?url";
import { Account, Transaction } from "./entities";
const driver = await SqlJsDriver.open({ locateFile: () => wasmUrl });
export const orm = new Orm(driver);
await orm.register(Account, Transaction);
// TransactionList.tsx
import { use } from "react";
import { orm } from "./orm";
import { Transaction } from "./entities";
export function TransactionList() {
const txs = use(
orm.findAll(Transaction, {
orderBy: [["id", "desc"]],
with: { account: true },
limit: 50,
}),
);
return <ul>{txs.map(tx => <li key={tx.id}>{use(tx.amount)}</li>)}</ul>;
}