Socket
Book a DemoInstallSign in
Socket

@prathammahajan/sequelize-query-builder

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@prathammahajan/sequelize-query-builder

πŸš€ 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

latest
Source
npmnpm
Version
1.0.4
Version published
Weekly downloads
8
-11.11%
Maintainers
1
Weekly downloads
Β 
Created
Source

πŸš€ 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: 'john@example.com' });

// 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: 'john@example.com'
});

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

OperatorDescriptionExample
$eqEqual{ age: { $eq: 25 } }
$neNot equal{ status: { $ne: 'inactive' } }
$gtGreater than{ age: { $gt: 18 } }
$gteGreater than or equal{ age: { $gte: 18 } }
$ltLess than{ age: { $lt: 65 } }
$lteLess than or equal{ age: { $lte: 65 } }
$likeLike pattern{ name: { $like: '%john%' } }
$inIn array{ status: { $in: ['active', 'pending'] } }
$betweenBetween values{ age: { $between: [18, 65] } }
$andLogical AND{ $and: [{ age: { $gte: 18 } }, { status: 'active' }] }
$orLogical OR{ $or: [{ name: 'John' }, { email: 'john@example.com' }] }

πŸ“ API Reference

QueryBuilder Methods

MethodDescription
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

  • Fork the repository
  • Create your feature branch (git checkout -b feature/amazing-feature)
  • Commit your changes (git commit -m 'Add amazing feature')
  • Push to the branch (git push origin feature/amazing-feature)
  • 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

Keywords

sequelize

FAQs

Package last updated on 27 Sep 2025

Did you know?

Socket

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.

Install

Related posts