Skip to content

Dialects & Clients

LinkedQL ships with clients for each SQL dialect supported.

For PostgreSQL, MySQL, and MariaDB, LinkedQL integrates directly with the corresponding native driver.

PostgreSQL

Use as a drop-in replacement for node-postgres.

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

const client = new PGClient({
  host: 'localhost',
  port: 5432,
  user: 'postgres',
  password: 'password',
  database: 'mydb',
  poolMode: false // defaults to pg.Client
});
await client.connect();

const res = await client.query('SELECT 1::text AS result');
console.log(res.rows); // [{ result: '1' }]

await client.disconnect();

Client Options

PGClient supports all options supported by node-postgres, including the following.

OptionTypeDefaultDescription
poolModebooleanfalseWhen true, uses pg.Pool; when false, uses pg.Client.

Realtime Setup

LinkedQL’s realtime behavior can be tuned via:

OptionTypeDefaultDescription
walSlotNamestring'linkedql_default_slot'Logical replication slot name used for change streaming.
walSlotPersistence0 | 1.0Slot lifecycle policy:
0 — ephemeral, droped by PostgreSQL at end of session;
1 — persistent, dropped/managed by you.
pgPublicationsstring | string[]'linkedql_default_publication'Publication name(s) to subscribe to for changes.

Logical Replication Required

To enable Live Queries, ensure PostgreSQL logical replication is enabled and, optionally, a publication is configured.

MySQL

Use in place of mysql2.

js
import { MySQLClient } from '@linked-db/linked-ql/mysql';

const client = new MySQLClient({
  host: 'localhost',
  port: 3306,
  user: 'root',
  password: 'password',
  database: 'mydb',
  poolMode: false // defaults to mysql.createConnection()
});
await client.connect();

const res = await client.query('SELECT 1 AS \`result\``);
console.log(res.rows); // [{ result: 1 }]

await client.disconnect();

Client Options

MySQLClient supports all options supported by mysql2, including the following.

OptionTypeDefaultDescription
poolModebooleanfalseWhen true, uses mysql.createPool(); when false, uses mysql.createConnection().

Realtime Setup

Live Queries for MySQL coming soon.

MariaDB

Use in place of mariadb/mysql2.

js
import { MariaDBClient } from '@linked-db/linked-ql/mariadb';

const client = new MariaDBClient({
  host: 'localhost',
  port: 3306,
  user: 'root',
  password: 'password',
  database: 'mydb'
});
await client.connect();

const res = await client.query('SELECT 1 AS \`result\``);
console.log(res.rows); // [{ result: 1 }]

await client.disconnect();

Client Options

MariaDBClient supports all options supported by mariadb.

Auto Pooling

MariaDBClient always runs on a connection pool.

Realtime Setup

Live Queries for MariaDB coming soon.

FlashQL

Use in place of SQLite, PGLite, and similar. Speaks both MySQL and PostgreSQL.

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

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

// PostgreSQL-style syntax (default)
const pgRes = await client.query('SELECT 1::text AS result');
console.log(pgRes.rows); // [{ result: '1' }]

// MySQL-style syntax (explicit dialect)
const myRes = await client.query('SELECT 1 AS `result`', { dialect: 'mysql' });
console.log(myRes.rows); // [{ result: 1 }]

await client.disconnect();

Client Options

FlashQL can be configured via a few options.

OptionTypeDefaultDescription
dialect'postgresql' | 'mysql''postgresql'Default parsing/execution dialect.
storageFlashQLStorageundefined(Coming soon) Storage target or adapter for persistent storage.

Realtime Setup

Realtime capabilities are built in. FlashQL maintains its own change events internally; no external replication setup is required.

MIT Licensed