npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

modular-orm

v0.3.51

Published

A simple ORM library for TypeScript that allows you to work with the database using classes

Downloads

79

Readme


| 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 |


Features

  • 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.

Examples

Full documentation text

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" } })