New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@linked-db/linked-ql

Package Overview
Dependencies
Maintainers
0
Versions
125
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@linked-db/linked-ql

A query client that extends standard SQL with new syntax sugars and enables auto-versioning capabilities on any database

  • 0.2.78
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
8
decreased by-93.89%
Maintainers
0
Weekly downloads
 
Created
Source

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:

  1. 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 SQL as LinkedQl
    import pg from 'pg';
    import LinkedQl from '@linked-db/linked-ql/sql';
    
    // Connect
    const pgClient = new pg.Client({
        host: 'localhost',
        port: 5432,
    });
    await pgClient.connect();
    
    // Use as a wrapper
    const linkedQlClient = new LinkedQl(pgClient, { dialect: 'postgres' });
    
  2. For the client-side IndexedDB database, import and instantiate the IDB language driver.

    IndexedDB is a low-level API for client-side storage.

    // Import IDB as LinkedQl
    import LinkedQl from '@linked-db/linked-ql/idb';
    
    // Create an instance.
    const linkedQlClient = new LinkedQl;
    
  3. 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 ODB as LinkedQl
    import LinkedQl from '@linked-db/linked-ql';
    
    // Create an instance.
    const LinkedQlClient = new LinkedQl;
    

All LinkedQl instances above implement the same interface:

  1. The LinkedQlClient.query() method lets you run any SQL query on your database.

    // Run a query
    client.query('SELECT fname, lname FROM users').then(result => {
        console.log(result);
    });
    
  2. Other methods give us a programmatic way to manipulate or query the database. (Docs coming soon.)

    1. The client.createDatabase() and client.createDatabaseIfNotExists() methods. (Returning a Database instance (database).)
    2. The client.dropDatabase() and client.dropDatabaseIfExists() methods.
    3. The client.databases() method - for listing databases, and the client.database(name) method - for obtaining a Database instance (database).
    4. The database.createTable(), database.alterTable(), and database.dropTable() methods.
    5. The database.tables() method - for listing tables, the database.table(name) method - for obtaining a Table instance (table).
    6. The table.getAll() method - for listing entries, the table.get(id) method - for obtaining an entry, the table.count() method - for count.
    7. The table.addAll() and table.add() methods.
    8. The table.putAll() and table.put() methods.
    9. 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.

Keywords

FAQs

Package last updated on 26 Jun 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc