import init, { BrowserDb } from "../../minigraf-wasm/minigraf.js";
async function main() {
await init();
const db = await BrowserDb.open("minigraf-demo");
await db.execute(`(transact [
[:alice :person/name "Alice"]
[:alice :person/age 30]
[:alice :friend :bob]
[:bob :person/name "Bob"]
])`);
const raw = await db.execute(`
(query [:find ?friend-name
:where [:alice :friend ?f]
[?f :person/name ?friend-name]])
`);
const result = JSON.parse(raw);
console.log("Alice's friends:", result.results.map(row => row[0]));
const blob = db.exportGraph();
console.log(".graph blob size:", blob.byteLength, "bytes");
const db2 = BrowserDb.openInMemory();
await db2.importGraph(blob);
const raw2 = await db2.execute(
`(query [:find ?name :where [?e :person/name ?name]])`
);
console.log("After import, names:", JSON.parse(raw2).results.map(r => r[0]));
}
main().catch(console.error);