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();
Errors
Common errors & fixes
Error: Cannot find module 'dsqlbase/schema'
Import path misspelled or package not installed
fixRun `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
fixUse 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
fixRun 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
fixUse additive migration pattern: add new column, copy data, drop old column
Audit
Dependencies
@electric-sql/pgliteoptionalPeer dependency for pglite session support (optional, if using pglite)
pgoptionalPeer dependency for PostgreSQL session support (required for pg adapter)