A lightweight TypeScript ORM for PostgreSQL.
bun add @woop-orm/core pg reflect-metadata
bun add -d @types/pgimport { WoopORM } from '@woop-orm/core';
WoopORM.connect({
type: 'postgres',
connectionString: process.env.DATABASE_URL,
});Use decorators to define your entities. This is cleaner and safer.
import { Model, Entity, Column } from '@woop-orm/core';
@Entity('users')
class User extends Model {
@Column()
id!: number;
@Column()
name!: string;
@Column({ name: 'email_address' }) // Map to different DB column
email!: string;
}// Create (Only decorated properties are sent to DB)
const user = await User.create({
name: 'Alice',
email: '[email protected]',
});
// Find by ID
const found = await User.find(user.id);
// Custom Query
const users = await User.query()
.where('email_address', '=', '[email protected]') // Use DB column name in queries
.orderBy('id', 'DESC')
.limit(10)
.get();- Decorators:
@Entityand@Columnfor declarative model definitions. - Safety: Only decorated properties are persisted, preventing accidental errors.
- Flexibility: Map class properties to different database column names.