Skip to content

Getting Started With LinkedQL

This guide takes you from installation to your first query with LinkedQL.

If you are totally new here, you may want to begin with What is LinkedQL. If you are here for the embeddable local runtime, jump to FlashQL.

Installation

Install the package from npm:

bash
npm install @linked-db/linked-ql

The package exports the client entry points.

Import and use the Client for your database. LinkedQL works the same across all clients.

ClientImport PathGuide
PGClient@linked-db/linked-ql/postgresPostgreSQL ↗
MySQLClient@linked-db/linked-ql/mysqlMySQL ↗
MariaDBClient@linked-db/linked-ql/mariadbMariaDB ↗
FlashQL@linked-db/linked-ql/flashqlFlashQL ↗
EdgeClient@linked-db/linked-ql/edgeEdge / Browser ↗
EdgeWorker@linked-db/linked-ql/edge-workerEdge Worker ↗

Your First Query: Direct Database Client

A good first look is with a regular database client.

js
import { PGClient } from '@linked-db/linked-ql/postgres';

const db = new PGClient({
  host: 'localhost',
  port: 5432,
  user: 'postgres',
  password: 'password',
  database: 'myapp',
});

await db.connect();

const result = await db.query('SELECT 10 AS value');
console.log(result.rows);
// [{ value: 10 }]

await db.disconnect();

Your First Query: Local Runtime With FlashQL

LinkedQL ships with FlashQL, an embeddable SQL runtime that runs in-process.

js
import { FlashQL } from '@linked-db/linked-ql/flashql';

const db = new FlashQL();
await db.connect();

await db.query(`
  CREATE TABLE public.users (
    id INT PRIMARY KEY,
    name TEXT
  );

  INSERT INTO public.users (id, name)
  VALUES (1, 'Ada'), (2, 'Linus');
`);

const result = await db.query(`
  SELECT id, name
  FROM public.users
  ORDER BY id
`);

console.log(result.rows);
// [{ id: 1, name: 'Ada' }, { id: 2, name: 'Linus' }]

await db.disconnect();

FlashQL has the same top-level query surface as the mainstream clients.

What Comes Next

While deliberately simple, the same interface above quickly opens into deeper grounds:

  • live queries with { live: true }
  • iterator-based querying with db.stream()
  • table-level changefeed subscriptions with db.wal.subscribe()
  • language extensions like DeepRefs and JSON literals
  • FlashQL orchestration with fedration, materialization, and sync

Where to Go Next

MIT Licensed