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. Speaks native PostgreSQL.

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 can be configured via a few options, including all options supported by node-postgres.

OptionTypeDefaultDescription
(all native options)Fully compatible with node-postgres driver configuration.
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 | 21Slot lifecycle policy:
0 — ephemeral, managed by PostgreSQL;
1 — ephemeral, managed by LinkedQL;
2 — persistent, assumes external/admin management.
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. Speaks native MySQL.

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 can be configured via a few options, including all options supported by mysql2.

OptionTypeDefaultDescription
(all native options)Fully compatible with mysql2 driver configuration.
poolModebooleanfalseWhen true, uses mysql.createPool(); when false, uses mysql.createConnection().

Realtime Setup

Live Queries for MySQL is coming soon. Current client usage is for standard query execution.

MariaDB

Use in place of mariadb. Speaks native MariaDB / MySQL.

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 can be configured via a few options, including all options supported by mariadb.

OptionTypeDefaultDescription
(all native options)Fully compatible with mariadb driver configuration.

Auto Pooling

MariaDBClient always runs on a connection pool.

Realtime Setup

Live Queries for MariaDB is coming soon. Current client usage is for standard query execution.

FlashQL

Use as an in-memory alternative to engines like SQLite or PGLite. Provides an embeddable SQL runtime and supports multiple dialects.

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

const client = new FlashClient();
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

FlashClient 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