Registry / database / offshore-sql

offshore-sql

JSON →
library1.0.9jsnpmunverified

SQL database adapter for the Offshore ORM, providing support for MySQL, PostgreSQL, and SQLite. Current stable version is 1.0.9. Release cadence is irregular, with infrequent updates. Key differentiator: bridges Offshore's query language to SQL backends, but note that Offshore itself is a less common ORM compared to alternatives like Sequelize or Knex. Requires offshore core as peer dependency. ESM-only from v1.0.0.

npm install offshore-sql
INSTALL
IMPORT
SIG · OFFSHORE-SQL
O
offshore-sql
databasejavascriptv1.0.9
harness data pending
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.

default (adapter)
import adapter from 'offshore-sql'
const adapter = require('offshore-sql')
ESM-only since v1.0.0. CommonJS require will fail.
type Adapter
import type { Adapter } from 'offshore-sql'
import { Adapter } from 'offshore-sql'
Type import only; Adapter is a TypeScript type, not a value.
AdapterConfig
import { AdapterConfig } from 'offshore-sql'
const { AdapterConfig } = require('offshore-sql')
Named export, ESM-only.

Initializes Offshore ORM with the SQL adapter, defines a model, and queries all users.

import offshore from 'offshore'; import sqlAdapter from 'offshore-sql'; import { AdapterConfig } from 'offshore-sql'; const config: AdapterConfig = { client: 'pg', connection: { host: process.env.DB_HOST ?? 'localhost', port: 5432, user: process.env.DB_USER ?? 'user', password: process.env.DB_PASSWORD ?? '', database: process.env.DB_NAME ?? 'mydb' } }; const orm = new offshore.Offshore(); orm.registerAdapter('sql', sqlAdapter(config)); const User = orm.defineModel('user', { attributes: { name: { type: 'string' }, email: { type: 'string', required: true } } }); async function run() { await orm.initialize(); const users = await User.find({}); console.log(users); await orm.teardown(); } run().catch(console.error);
Debug
Known issues
breakingoffshore-sql v1.0.0 dropped CommonJS support. All imports must use ESM syntax.
fix
Use import statements instead of require().
affects: >=1.0.0
gotchaThe adapter does not automatically create tables; you must run migrations or sync manually.
fix
Use offshore's migrate or sync methods after initializing.
affects: <=1.0.9
deprecatedSupport for MySQL 5.x is deprecated; MySQL 8+ recommended.
fix
Upgrade MySQL to version 8 or later.
affects: >=1.0.5
gotchaTransactions are not supported in this adapter; use raw queries via knex.
fix
Access the underlying knex instance via adapter.knex to run transactions.
affects: <=1.0.9
Errors
Common errors & fixes
Error: Cannot find module 'offshore-sql'
Package not installed or ESM module resolution issue.
fix
Run 'npm install offshore-sql' and ensure your package.json has 'type': 'module' or use .mjs extension.
TypeError: adapter is not a function
Attempted to use CommonJS require() on ESM-only module.
fix
Replace require('offshore-sql') with import adapter from 'offshore-sql'.
Error: connect ECONNREFUSED ::1:5432
Database server not running or connection config incorrect.
fix
Verify DB_HOST, port, and that the database service is started.
Upgrade
Version history
1.0.9latest on npm
Audit
Dependencies
offshorerequiredPeer dependency: the adapter requires offshore ORM core to function.
Agent activity
7 hits · last 30 days
node
6
Resources
offshore-sql — npm install offshore-sql · libregistry