Swan ORM is a lightweight ORM for Node.js and PostgreSQL, designed for TypeScript-first development. The current stable version is 1.0.9. It provides a simple, intuitive API for defining models, querying with chainable methods, and managing database migrations. Key differentiators include zero external runtime dependencies, automatic type inference from models, and a focus on PostgreSQL-specific features. Compared to larger ORMs like Sequelize or TypeORM, Swan ORM offers minimal overhead and a simpler learning curve, suitable for projects that need quick setup without heavy abstraction.
npm install swan-ormNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates connecting to PostgreSQL, defining a User model with Swan ORM decorators, syncing the schema, and performing basic CRUD operations.
Rewrite models as classes extending Model and instantiate Swan with a pg Client.
Use swan.registerType('mytype', ...) prior to model definition.Use @Column({ type: 'serial', primaryKey: true }) instead.Use 'import { Swan } from 'swan-orm'' and ensure the project uses ES modules (type: 'module' in package.json).Instantiate Swan with a pg.Client or pg.Pool instance.
Add await swan.sync() after instantiating Swan and before performing queries.