Registry / database / orbit-sql

orbit-sql

JSON →
library0.4.2jsnpmunverified

SQL support for Orbit, a library for managing data synchronization and caching in JavaScript applications. orbit-sql provides SQL query building via Knex for server-side Orbit apps using PostgreSQL, MySQL, or SQLite. Current stable version is 0.4.2. The library integrates with the Orbit ecosystem, enabling SQL-backed records and queries. It is released on an as-needed basis, with a focus on Knex-based SQL support rather than raw queries. Key differentiators: built specifically for Orbit's data model, leverages Knex for cross-dialect compatibility, and provides typed query results in TypeScript.

database
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

ESM is preferred; CommonJS require works with TypeScript esModuleInterop. Ensure Orbit is also imported.

import { SQLRecord } from 'orbit-sql'

Default export is the orbitSQL object; named exports also available.

import orbitSQL from 'orbit-sql'

Tree-shakable named imports reduce bundle size.

import { SQLRecord } from 'orbit-sql'

Sets up an in-memory SQLite database with Knex and runs a query using orbit-sql.

import orbitSQL from 'orbit-sql'; import { SQLRecord } from 'orbit-sql'; import Knex from 'knex'; const knexConfig = { client: 'sqlite3', useNullAsDefault: true, connection: { filename: ':memory:' } }; const db = Knex(knexConfig); const sql = orbitSQL({ db }); // Create a record type const userType = { type: 'user', attributes: { name: { type: 'string' } } }; // Query sql.query((q) => q.type('user').filter({ name: 'Alice' })).then(results => { console.log(results); });
Debug
Known footguns
gotchaKnex instance must be provided directly. orbit-sql does not manage connections; you must handle connection pooling and cleanup.
gotchaimport { SQLRecord } from 'orbit-sql' requires TypeScript's esModuleInterop or hasModule option enabled for CommonJS bundling.
breakingVersion 0.4.0 changed the export structure; named exports like 'SQLRecord' were moved to a subpath. Check import statements.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
6 hits · last 30 days
gptbot
3
Resources