Registry / database / dsqlbase

dsqlbase

JSON →
library0.1.6jsnpmunverified

dsqlbase is an ORM and migration toolkit designed specifically for AWS Aurora DSQL, a distributed SQL database. Current stable version is 0.1.6. It is in early-stage development and not production-ready. Key differentiators: enforces DSQL constraints (no foreign keys, no in-place column changes, async-only index builds), refuses unsupported DDL, emits DSQL-shaped SQL by default. Ships TypeScript types. Requires peer dependencies @electric-sql/pglite ^0.4.5 and pg ^8.20.0.

npm install dsqlbase
INSTALL
IMPORT
SIG · DSQLBASE
D
dsqlbase
databasejavascriptv0.1.6
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.

table
import { table } from 'dsqlbase/schema'
const { table } = require('dsqlbase')
Schema utilities are in subpath 'dsqlbase/schema'
createClient
import { createClient } from 'dsqlbase'
import { createClient } from 'dsqlbase/client'
Main client export is from 'dsqlbase'
createPgSession
import { createPgSession } from 'dsqlbase/pg'
import { createPgSession } from 'dsqlbase'
Session adapter for pg is in subpath 'dsqlbase/pg'
createPgliteSession
import { createPgliteSession } from 'dsqlbase/pglite'
import { createPgliteSession } from 'dsqlbase'
Session adapter for @electric-sql/pglite is in subpath 'dsqlbase/pglite'

Defines a schema with teams and projects tables using dsqlbase schema helpers, sets up a pg session, creates a client, and queries projects with a join.

import { table, uuid, text, datetime, relations, hasMany, belongsTo } from 'dsqlbase/schema'; import { Pool } from 'pg'; import { createPgSession } from 'dsqlbase/pg'; import { createClient } from 'dsqlbase'; export const teams = table('teams', { id: uuid('id').primaryKey().defaultRandom(), name: text('name').notNull(), createdAt: datetime('created_at').notNull().defaultNow(), }); export const projects = table('projects', { id: uuid('id').primaryKey().defaultRandom(), teamId: uuid('team_id').notNull(), name: text('name').notNull(), }); export const teamRelations = relations(teams, { projects: hasMany(projects, { from: [teams.columns.id], to: [projects.columns.teamId], }), }); export const projectRelations = relations(projects, { team: belongsTo(teams, { from: [projects.columns.teamId], to: [teams.columns.id], }), }); const session = createPgSession(new Pool({ connectionString: process.env.DATABASE_URL ?? '' })); export const dsql = createClient({ schema: { teams, projects, teamRelations, projectRelations }, session }); async function main() { const recent = await dsql.projects.findMany({ orderBy: { name: 'asc' }, limit: 10, join: { team: true } }); console.log(recent); } main();
Debug
Known issues
gotchadsqlbase does not support foreign keys or in-place column changes; DDL that violates DSQL constraints will be rejected at runtime
fix
Design schema without foreign keys; use additive migrations (add column, then migrate data, then drop old column)
affects: >=0.0.0
gotchaAll index builds in DSQL are asynchronous; dsqlbase does not wait for index creation to complete
fix
Use a separate mechanism to verify index completion before relying on query performance
affects: >=0.0.0
deprecatedThe package is in early-stage development (v0.1.6) and not production-ready; APIs may change without notice
fix
Pin to a specific version and test thoroughly before upgrading
affects: >=0.1.0
gotchaBearer token authentication may be required for DSQL; dsqlbase does not handle token generation or rotation
fix
Use AWS SDK or IAM authentication to generate a token and pass it as password in the connection string
affects: >=0.0.0
Errors
Common errors & fixes
Error: Cannot find module 'dsqlbase/schema'
Import path misspelled or package not installed
fix
Run `npm install dsqlbase` and ensure import is from 'dsqlbase/schema' (not 'dsqlbase')
TypeError: createPgSession is not a function
Importing createPgSession from wrong path or using default import incorrectly
fix
Use named import: `import { createPgSession } from 'dsqlbase/pg'`
Error: relation "teams" does not exist
Table not created in DSQL database yet; migrations need to be run
fix
Run migration script using dsqlbase's migration utilities or create tables manually with allowed DDL
error: cannot use "in-place column type change" on DSQL
DSQL does not support ALTER COLUMN TYPE; dsqlbase blocks such DDL
fix
Use additive migration pattern: add new column, copy data, drop old column
Upgrade
Version history
0.1.6latest on npm
Audit
Dependencies
@electric-sql/pgliteoptionalPeer dependency for pglite session support (optional, if using pglite)
pgoptionalPeer dependency for PostgreSQL session support (required for pg adapter)
Agent activity
10 hits · last 30 days
node
8
Resources
dsqlbase — npm install dsqlbase · libregistry