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

@prathammahajan/sequelize-query-builder

v1.0.4

Published

πŸš€ Advanced Sequelize query builder with pagination, filtering, sorting, and performance monitoring. TypeScript-first, enterprise-ready, production-grade database abstraction layer for Node.js applications. Features advanced SQL query building, optimized

Readme

πŸš€ Sequelize Advanced Query Builder

Powerful, type-safe query builder for Sequelize with pagination, filtering, sorting, and performance monitoring.

SEO Keywords: Advanced Sequelize query builder, TypeScript ORM, database pagination, SQL filtering, query optimization, performance monitoring, Node.js database layer, enterprise-ready ORM, scalable database queries, production-ready query builder

npm version License: MIT TypeScript

GitHub stars GitHub forks GitHub watchers

✨ Features

  • πŸ” Advanced Filtering - Complex queries with operators
  • πŸ“„ Smart Pagination - Page-based and offset-based pagination
  • πŸ”„ Flexible Sorting - Multi-column sorting with null handling
  • πŸ”— Easy Joins - Simple join operations
  • ⚑ Performance Monitoring - Built-in query performance tracking
  • πŸ›‘οΈ Type Safety - Full TypeScript support
  • 🎯 Error Handling - Custom error classes for better debugging

🎯 Why Choose This Query Builder?

Perfect for developers who need:

  • Enterprise-grade database operations with advanced query building capabilities
  • TypeScript-first development with full type safety and IntelliSense support
  • Performance optimization with built-in monitoring and caching
  • Scalable architecture for large-scale applications
  • Production-ready solutions with comprehensive error handling
  • Developer-friendly APIs with intuitive method chaining
  • Extensible middleware system for custom functionality
  • Cross-database compatibility supporting MySQL, PostgreSQL, SQLite, and MariaDB

πŸ“¦ Installation

npm install @prathammahajan/sequelize-query-builder

πŸš€ Quick Start

const { createQueryBuilder } = require('@prathammahajan/sequelize-query-builder');

// Create query builder
const userBuilder = createQueryBuilder(User, {
  defaultPageSize: 10,
  enablePerformanceMonitoring: true
});

// Advanced query with pagination, filtering, and sorting
const result = await userBuilder
  .withPagination({ page: 1, pageSize: 10 })
  .withFilters({ isActive: true, name: 'John' })
  .withSorting({ column: 'createdAt', order: 'DESC' })
  .execute();

console.log(result.data);        // Array of users
console.log(result.pagination);  // Pagination info
console.log(result.performance); // Performance metrics

πŸ“‹ Basic Usage

Simple Queries

// Find all active users
const users = await userBuilder.findAll({ isActive: true });

// Find one user
const user = await userBuilder.findOne({ email: '[email protected]' });

// Count users
const count = await userBuilder.count({ isActive: true });

Pagination

const result = await userBuilder
  .withPagination({ page: 2, pageSize: 20 })
  .execute();

// Result includes:
// - data: Array of results
// - pagination: { page, pageSize, total, totalPages, hasNext, hasPrev }

Filtering

const result = await userBuilder
  .withFilters({
    isActive: true,
    age: { $gte: 18 },
    name: { $like: '%john%' }
  })
  .execute();

Sorting

const result = await userBuilder
  .withSorting([
    { column: 'createdAt', order: 'DESC' },
    { column: 'name', order: 'ASC' }
  ])
  .execute();

Joins

const result = await userBuilder
  .withJoins(['profile', 'orders'])
  .execute();

πŸ”§ Configuration

const userBuilder = createQueryBuilder(User, {
  defaultPageSize: 10,           // Default page size
  maxPageSize: 100,              // Maximum page size
  enableQueryLogging: true,      // Log queries
  enablePerformanceMonitoring: true, // Track performance
  allowedSortColumns: ['name', 'email', 'createdAt'],
  allowedJoinModels: ['Profile', 'Orders']
});

🎯 Advanced Examples

Complex Query

const result = await userBuilder
  .withPagination({ page: 1, pageSize: 25 })
  .withFilters({
    isActive: true,
    age: { $between: [18, 65] },
    $or: [
      { name: { $like: '%john%' } },
      { email: { $like: '%john%' } }
    ]
  })
  .withSorting({ column: 'createdAt', order: 'DESC' })
  .withJoins(['profile'])
  .execute();

CRUD Operations

// Create
const newUser = await userBuilder.create({
  name: 'John Doe',
  email: '[email protected]'
});

// Update
const updated = await userBuilder.updateByPk(1, {
  name: 'John Updated'
});

// Delete
await userBuilder.destroyByPk(1);

πŸ“Š Performance Monitoring

const result = await userBuilder
  .withPerformanceMonitoring()
  .execute();

console.log(result.performance);
// {
//   executionTime: 45,
//   queryCount: 2,
//   cacheHit: false
// }

πŸ› οΈ TypeScript Support

import { createQueryBuilder, QueryBuilderConfig } from '@prathammahajan/sequelize-query-builder';

const userBuilder = createQueryBuilder(User, {
  defaultPageSize: 10
} as QueryBuilderConfig);

// Full type safety and IntelliSense support

πŸ” Filter Operators

| Operator | Description | Example | |----------|-------------|---------| | $eq | Equal | { age: { $eq: 25 } } | | $ne | Not equal | { status: { $ne: 'inactive' } } | | $gt | Greater than | { age: { $gt: 18 } } | | $gte | Greater than or equal | { age: { $gte: 18 } } | | $lt | Less than | { age: { $lt: 65 } } | | $lte | Less than or equal | { age: { $lte: 65 } } | | $like | Like pattern | { name: { $like: '%john%' } } | | $in | In array | { status: { $in: ['active', 'pending'] } } | | $between | Between values | { age: { $between: [18, 65] } } | | $and | Logical AND | { $and: [{ age: { $gte: 18 } }, { status: 'active' }] } | | $or | Logical OR | { $or: [{ name: 'John' }, { email: '[email protected]' }] } |

πŸ“ API Reference

QueryBuilder Methods

| Method | Description | |--------|-------------| | findAll(where?) | Find all records | | findOne(where) | Find one record | | findByPk(id) | Find by primary key | | count(where?) | Count records | | create(data) | Create new record | | updateByPk(id, data) | Update by primary key | | destroyByPk(id) | Delete by primary key | | withPagination(options) | Add pagination | | withFilters(filters) | Add filters | | withSorting(sorting) | Add sorting | | withJoins(joins) | Add joins | | execute() | Execute query | | executeWithCount() | Execute with count |

🀝 Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸš€ Use Cases & Applications

Ideal for:

  • E-commerce platforms requiring complex product filtering and pagination
  • Content management systems with advanced search and sorting capabilities
  • Analytics dashboards needing efficient data aggregation and reporting
  • API development with RESTful endpoints requiring flexible querying
  • Microservices architecture with database abstraction layers
  • Real-time applications requiring optimized database performance
  • Enterprise software with complex business logic and data relationships
  • Startup MVPs needing rapid development with production-ready database operations

πŸ” SEO & Discoverability

Search Terms: Sequelize query builder, TypeScript ORM, Node.js database layer, advanced SQL queries, database pagination, query optimization, performance monitoring, enterprise ORM, scalable database operations, production-ready query builder, MySQL query builder, PostgreSQL query builder, database abstraction layer, repository pattern implementation, data access layer, query performance optimization, database middleware, SQL query optimization, TypeScript database library, Node.js ORM extension

πŸ™ Support


Made with ❀️ by Pratham Mahajan