PitchHut logo
MasqueradeORM
Seamless and lightweight ORM for Node.js in TypeScript and JavaScript.
Pitch

MasqueradeORM simplifies database interactions in Node.js by allowing seamless use of your own classes without complex ORM constraints. It generates schemas directly from your class definitions, reducing setup and improving maintainability. Effortlessly manage SQLite and PostgreSQL databases while enjoying powerful IntelliSense support for confident coding.

Description

MasqueradeORM is a lightweight Object-Relational Mapping (ORM) tool designed for Node.js applications, fully compatible with both TypeScript and JavaScript. It streamlines the development process by allowing developers to utilize their own class definitions without the need to conform to intricate ORM-specific models or metadata systems.

Key Features:

  • Effortless Setup: Utilize your existing classes without requiring extensive configuration.
  • Automatic Schema Generation: Skip the complexities of schema planning as tables and schemas are generated directly from class definitions.
  • Enhanced Developer Experience: Features powerful IntelliSense for building complex queries, ensuring robust guidance and instant feedback through real-time IDE support.
  • Efficient Memory Usage: Manages a single in-memory representation per database row through an Entity Map, preventing duplicates and enhancing performance.
  • Optimized Data Transactions: Batches database operations to minimize round-trips and maintain data integrity.
  • Flexible Query Capabilities: Craft sophisticated WHERE and ORDER BY conditions easily, with full support for relational and non-relational data, while automatically managing necessary joins.
  • Expressive Condition Building: Write clear, complex conditions in your queries using template-literal syntax, augmented by IntelliSense support.
  • Advanced Sorting: Supports intricate sorting options including aggregated results and custom expressions.
  • Robust Relationship Management: Offers comprehensive support for various relationship types, including eager and lazy loading, and enables modifications of associations regardless of load state.
  • Security: Automatically safeguards against SQL injection through parameterized queries.
  • Lightweight Framework: Requires only two dependencies, making it easy to integrate into existing projects.
  • Automatic Schema Cleanup: Identifies and provides a method for the resolution of unused tables and columns, thus enhancing database performance.

Supported SQL Clients:

  • SQLite
  • PostgreSQL

Example Code Implementation:

To create an ORM-compatible class:

import { Entity } from 'masquerade';

type UserSettings = {
    theme: 'light' | 'dark' | 'system';
    twoStepVerification: boolean;
    locale: 'en' | 'es' | 'fr' | 'de';
};

export class User extends Entity {
    username: string;
    email: string;
    password: string;
    createdAt: Date = new Date();
    friendList: User[] = [];
    settings: UserSettings & object = {
        locale: "en",
        theme: "system",
        twoStepVerification: false
    };

    constructor(username: string, email: string, password: string) {
        super();
        this.username = username;
        this.email = email;
        this.password = password;
    }
}

To perform a simple query to find a user by email:

async function findUserByEmail(lookupEmail: string): Promise<User | undefined> {
    const resultArray = await User.find({ where: { email: lookupEmail }});
    return resultArray[0];
}

MasqueradeORM provides a comprehensive solution for developers looking for an intuitive way to manage database operations while keeping code clean and maintainable. For further insights into setup and advanced capabilities, refer to the documentation.

This ORM balances the convenience of embedded SQLite with the strength of strong typing required in RDBMS applications, creating an efficient and versatile framework for modern web development.

0 comments

No comments yet.

Sign in to be the first to comment.