Using Apache Ignite from a TypeScript Agent
The TypeScript SDK already includes the host module declaration for golem:rdbms/ignite2@1.5.0.
Imports
import { DbConnection, type DbValue } from "golem:rdbms/ignite2@1.5.0";Open a Connection
Ignite uses thin-client URLs like ignite://host:10800.
const conn = DbConnection.open("ignite://127.0.0.1:10800");Query Data
Ignite placeholders use ?.
const result = conn.query("SELECT ?", [{ tag: "db-string", val: "hello" } satisfies DbValue]);
const value = result.rows[0]?.values[0];
if (!value || value.tag !== "db-string") {
throw new Error(`Unexpected Ignite value: ${JSON.stringify(value)}`);
}
const message = value.val;Execute Statements
conn.execute(
`CREATE TABLE IF NOT EXISTS notes (
id INT PRIMARY KEY,
body VARCHAR
) WITH "CACHE_NAME=notes"`,
[],
);Include WITH "CACHE_NAME=..." when creating tables through Ignite SQL.
Transactions
const tx = conn.beginTransaction();
tx.execute("INSERT INTO notes (id, body) VALUES (?, ?)", [
{ tag: "db-int", val: 1 },
{ tag: "db-string", val: "hello" },
]);
tx.commit();