The JS SDK, running live
inlaysql-js is the JavaScript face of the engine: a typed core, storage adapters, an ORM — zero runtime dependencies, plain ESM files, no build step. This page imports those exact source files and runs a model end to end.
const Page = defineModel("pages", {
id: field.integer().primaryKey(),
title: field.text(),
body: field.text().index("bm25"),
embedding: field.vector(64).index("hnsw").embedFrom("body"),
});
const db = await openDatabase({ source: memory(), create: true });
await install(db, Page);
await repo(db, Page).insert([
{ title: "Renew a passport", body: "Renew online in three steps; ten working days." },
{ title: "File your tax return", body: "Returns are due by 30 June." },
]);
const hits = await repo(db, Page).search("renew a passport", { limit: 1 });
loading the SDK…