NestJS Query adapter for MikroORM
npm install nestjs-query-mikro-ormA NestJS Query adapter for MikroORM.
This library provides a seamless integration between NestJS Query and MikroORM, allowing you to build powerful GraphQL APIs with minimal boilerplate.
- 🚀 Full NestJS Query support with MikroORM
- 📦 Type-safe query building
- 🔍 Advanced filtering and sorting
- 🔗 Relation query support
- 📊 Aggregation queries
- 🎯 Soft delete support
- ✨ Built with TypeScript
- 📦 Dual-format support (ESM & CommonJS)
This package supports both ES Modules (ESM) and CommonJS (CJS) for maximum compatibility across different Node.js environments and bundlers.
- ESM: import { MikroOrmQueryService } from 'nestjs-query-mikro-orm'
- CommonJS: const { MikroOrmQueryService } = require('nestjs-query-mikro-orm')
The package automatically detects the import method and serves the appropriate format.
``bash
pnpm add nestjs-query-mikro-orm
Quick Start
$3
`typescript
import { NestQueryMikroOrmModule } from 'nestjs-query-mikro-orm';
import { Module } from '@nestjs/common';
import { UserEntity } from './user.entity';@Module({
imports: [NestQueryMikroOrmModule.forFeature([UserEntity])],
})
export class UserModule {}
`$3
`typescript
import { Entity, PrimaryKey, Property } from '@mikro-orm/core';@Entity()
export class UserEntity {
@PrimaryKey()
id!: number;
@Property()
name!: string;
@Property()
email!: string;
@Property()
createdAt: Date = new Date();
}
`$3
`typescript
import { Injectable } from '@nestjs/common';
import { MikroOrmQueryService } from 'nestjs-query-mikro-orm';
import { UserEntity } from './user.entity';@Injectable()
export class UserService extends MikroOrmQueryService {
// Your custom methods here
}
`Development
$3
- Node.js >= 18
- pnpm >= 9
$3
`bash
Install dependencies
pnpm installSetup git hooks
pnpm prepare
`$3
`bash
Build the library
pnpm buildBuild in watch mode
pnpm devRun tests
pnpm testRun tests in watch mode
pnpm test:watchRun tests with coverage
pnpm test:coverageLint code
pnpm lintFix lint issues
pnpm lint:fixFormat code
pnpm formatCheck formatting
pnpm format:checkType check
pnpm typecheck
`$3
This project uses Husky for git hooks:
- pre-commit: Runs lint-staged to format and lint staged files
- pre-push: Runs lint, typecheck, and tests before pushing
- commit-msg: Validates commit messages using commitlint
$3
This project follows Conventional Commits:
`bash
feat: add new feature
fix: fix bug
docs: update documentation
style: format code
refactor: refactor code
test: add tests
chore: update dependencies
`License
MIT
Author
Manuel Antunes
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
1. Fork the repository
2. Create your feature branch (
git checkout -b feature/amazing-feature)
3. Commit your changes (git commit -m 'feat: add amazing feature')
4. Push to the branch (git push origin feature/amazing-feature`)