Installation
Installation
Section titled “Installation”Install the core package plus the adapters you actually use.
pnpm add jsorm jsorm-pg jsorm-sqlite jsorm-mysqlpnpm installPackage roles
Section titled “Package roles”jsorm— model system, query AST, migrations, CLI, adapter contractsjsorm-pg— PostgreSQL adapterjsorm-mysql— MySQL adapterjsorm-sqlite— SQLite adapter
Minimal setup
Section titled “Minimal setup”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, }, }),});Optional peer dependencies
Section titled “Optional peer dependencies”Adapter packages rely on official drivers through optional peer dependencies. Install the adapter package and its driver together in the application that uses it.
Best practices
Section titled “Best practices”- Install only the adapter packages you need in each service.
- Keep environment variables outside application code.
- Reuse one shared connection module instead of creating ad-hoc database instances.