Skip to content

Installation

Install the core package plus the adapters you actually use.

Terminal window
pnpm add jsorm jsorm-pg jsorm-sqlite jsorm-mysql
pnpm install
  • jsorm — model system, query AST, migrations, CLI, adapter contracts
  • jsorm-pg — PostgreSQL adapter
  • jsorm-mysql — MySQL adapter
  • jsorm-sqlite — SQLite adapter
import { connectionDB } from 'jsorm';
import { pgAdapter } from 'jsorm-pg';
export const db = connectionDB({
adapter: pgAdapter({
name: 'main',
connectionString: process.env.DATABASE_URL!,
pool: {
min: 2,
max: 10,
},
}),
});

Adapter packages rely on official drivers through optional peer dependencies. Install the adapter package and its driver together in the application that uses it.

  1. Install only the adapter packages you need in each service.
  2. Keep environment variables outside application code.
  3. Reuse one shared connection module instead of creating ad-hoc database instances.