
Security News
Opengrep Adds Apex Support and New Rule Controls in Latest Updates
The latest Opengrep releases add Apex scanning, precision rule tuning, and performance gains for open source static code analysis.
modular-orm
Advanced tools
A simple ORM library for TypeScript that allows you to work with the database using classes
Lightweight, fully object-oriented ORM library for TypeScript and MySQL. It is designed for simplicity and strong type safety, with a class-based API built around decorators.
Description | Result |
---|---|
Sending 100.000 INSERT queries | 13s |
Selecting 100.000 objects with DTO | 79ms |
Lines of code needed to connect | 7 |
Test coverage | 66.82% |
Dist size | 340kb |
Fully OOP Structure: Define tables, columns, and relationships using TypeScript classes.
Minimal Setup: Simple to configure and get started with-just a few lines of code.
Up and down migrations with files (or auto)
Class-Based DTO Mapping: Map query results to custom classes using @Result()
decorators.
Repository Pattern Out of the Box: Create repositories with new Repository(Class)
- no boilerplate or registration needed.
Validation and Transforms: Add validation and data transformation logic directly to your models with built-in or custom tools.
Logger: you can add logger method in your module and handle all queries
Intuitive architecture: repository.find({ userId: [1, 2] })
- select all from ur table where userId is 1 or 2
Caching: build-in in-memory cache system without Redis
and flexible settings
Typed Information Schema Access: Query database metadata through typed APIs.
And more. You can see examples in GitHub repository
ModularORM is ideal for developers who want a clean, type-safe ORM experience with full control and minimal overhead.
Connecting to the database
const main : ModularORM = ModularORM.getInstance()
await main.start({
host: 'localhost',
user: 'root',
password: '1',
database: 'orm',
port: 3306,
connectionType: 'pool',
checkTablesExists: false, // If you want to check if tables are created. If not, it will be IF NOT EXISTS
validationErrors: false // You can enable this to make validation errors throw real exceptions.
// And maaany more parameters
})
Creating tables
@Table({ comment: 'Users table' })
@NamedTable('users')
class Users extends Module {
@AutoIncrementId()
public id!: number;
@Column({ type: ColumnType.VARCHAR(64), notNull: true, comment: 'Users first name', index: true })
public first_name!: string;
@Column({ type: ColumnType.VARCHAR(64), notNull: true, comment: 'Users last name', index: true })
public last_name!: string;
@Column({ type: ColumnType.FLOAT, notNull: true, comment: 'Users balance', defaultValue: 0 })
public money!: number;
}
Creating DTOs with validation and transforms
class UserDTO implements Validate {
@Result() // Can be empty
public id!: number;
@Result('first_name')
@IsSafeString() // Validator
public firstName!: string;
@Result('last_name')
@IsSafeString() // Validator
public lastName!: string;
@Result()
@ToNumber() // Transform
public money!: number;
public validateErrors: Set<string> = new Set(); // Validation errors
}
Creating repository
const repo = new Repository(Users, UserDTO); // With DTO
const repotwo = new Repository(Users); // Without DTO
Queries
// SELECT * FROM users WHERE first_name = "Alex" OR last_name = "Smith"
const res : Users[] = await repotwo.find({ first_name: ["Alex"], last_name: "Smith" })
// SELECT * FROM users WHERE (id = 1 OR id = 2) ORDER BY id DESC LIMIT 1
const restwo : UserDTO[] = await repo.find({ id: [1, 2] }, { limit: 1, order: { id: "DESC" } })
0.3.51 | 02.07.2025
FAQs
A simple ORM library for TypeScript that allows you to work with the database using classes
The npm package modular-orm receives a total of 9 weekly downloads. As such, modular-orm popularity was classified as not popular.
We found that modular-orm demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The latest Opengrep releases add Apex scanning, precision rule tuning, and performance gains for open source static code analysis.
Security News
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
Research
/Security News
A RubyGems malware campaign used 60 malicious packages posing as automation tools to steal credentials from social media and marketing tool users.