Linked QL
A query client that extends standard SQL with new syntax sugars for simpler queries and enables auto-versioning capabilities on any database. And what's more, ready to talk to any DB!
-
Magic Paths. Express relationships graphically. Meet the magic path operators that leverage heuristics to let you connect to columns on other tables without writing a JOIN.
-
Auto-Versioning. Create, Drop, Alter schemas without needing to manually version each operation. Linked QL automatically adds auto-versioning capabilities to your database.
-
Omni-DB. Talk to YOUR DB of choice - from the server-side PostgreSQL and MySQL, to the client-side IndexedDB, to the plain JSON object. One syntax to rule them all.
Linked QL wraps all the powerful concepts in a simple, succint API.
Basic Usage
Install Linked QL:
npm install @linked-db/linked-ql
Obtain the Linked QL client for your target database:
-
For SQL databases, install the regular SQL client you use for your DB - pg
for PostgreSQL, mysql2
for MySQL databases:
npm install pg
Import and instantiate Linked QL over your DB client:
import pg from 'pg';
import LinkedQl from '@linked-db/linked-ql/sql';
const pgClient = new pg.Client({
host: 'localhost',
port: 5432,
});
await pgClient.connect();
const linkedQlClient = new LinkedQl(pgClient, { dialect: 'postgres' });
-
For the client-side IndexedDB database, import and instantiate the IDB language driver.
IndexedDB is a low-level API for client-side storage.
import LinkedQl from '@linked-db/linked-ql/idb';
const linkedQlClient = new LinkedQl;
-
To work with Linked QL's in-memory object storage, import and instantiate the ODB language driver.
This is an environment-agnostic in-memory store.
import LinkedQl from '@linked-db/linked-ql';
const LinkedQlClient = new LinkedQl;
All LinkedQl
instances above implement the same interface:
-
The LinkedQlClient.query()
method lets you run any SQL query on your database.
client.query('SELECT fname, lname FROM users').then(result => {
console.log(result);
});
-
Other methods give us a programmatic way to manipulate or query the database. (Docs coming soon.)
- The
client.createDatabase()
and client.createDatabaseIfNotExists()
methods. (Returning a Database
instance (database
).) - The
client.dropDatabase()
and client.dropDatabaseIfExists()
methods. - The
client.databases()
method - for listing databases, and the client.database(name)
method - for obtaining a Database
instance (database
). - The
database.createTable()
, database.alterTable()
, and database.dropTable()
methods. - The
database.tables()
method - for listing tables, the database.table(name)
method - for obtaining a Table
instance (table
). - The
table.getAll()
method - for listing entries, the table.get(id)
method - for obtaining an entry, the table.count()
method - for count. - The
table.addAll()
and table.add()
methods. - The
table.putAll()
and table.put()
methods. - The
table.deleteAll()
and table.delete()
methods.
Learn more about the API. (DOCS coming soon.)
What About Relationships? - The Language
Objective SQL is a superset of the same familiar, powerful SQL language you know...
SELECT post_title, users.fname AS author_name FROM posts
LEFT JOIN users ON users.id = posts.author_id;
...with an object-oriented syntax for relationships, built into the language...
SELECT post_title, author_id->fname AS author_name FROM posts;
...and that's SQL without the query complexity!
Learn more about the language and see just what's possible with the arrow syntax. (DOCS coming soon.)
Documentation
Objective SQL Documentions
Issues
To report bugs or request features, please submit an issue to this repository.
License
MIT.