Skip to content

Conversation

@jtomaszewski
Copy link
Contributor

@jtomaszewski jtomaszewski commented Dec 8, 2025

Summary

  • Add @ptc-org/nestjs-query-mikroorm package that provides MikroORM integration
  • Implements MikroOrmQueryService following the QueryService interface from @ptc-org/nestjs-query-core
  • Provides NestjsQueryMikroOrmModule.forFeature() for easy module registration
  • Comprehensive test suite with 62 tests covering all operations

Test plan

  • FilterQueryBuilder converts all filter operations correctly
  • MikroOrmQueryService implements query, count, findById, getById
  • MikroOrmQueryService implements createOne, createMany
  • MikroOrmQueryService implements updateOne, updateMany
  • MikroOrmQueryService implements deleteOne, deleteMany
  • MikroOrmQueryService implements relation queries
  • NestjsQueryMikroOrmModule.forFeature() creates providers correctly
  • Soft delete support works as expected

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added a new MikroORM query integration package with full CRUD operations, advanced filtering, sorting, and pagination support.
    • Introduced soft-delete functionality for entities.
    • Added relation management capabilities for querying and modifying entity relationships.
    • Automated preview publishing workflow for pull requests.
  • Chores

    • Added MikroORM dependencies and build configurations.

✏️ Tip: You can customize this high-level summary in your review settings.

jtomaszewski and others added 3 commits December 8, 2025 09:07
Enable preview package releases on pull requests and workflow dispatch
using pkg.pr.new. This allows testing packages before official release.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
feat(ci): add pkg.pr.new preview releases
Add `@ptc-org/nestjs-query-mikroorm` package that provides MikroORM integration:

- MikroOrmQueryService implementing full QueryService interface
- NestjsQueryMikroOrmModule.forFeature() for easy module registration
- FilterQueryBuilder for converting nestjs-query filters to MikroORM queries
- Support for all filter operations (eq, neq, gt, gte, lt, lte, in, notIn, like, iLike, is, isNot, and, or)
- Support for sorting with nulls first/last
- Support for pagination
- Relation queries (queryRelations, countRelations, findRelation)
- Relation mutations (addRelations, setRelations, setRelation, removeRelations, removeRelation)
- Soft delete support
- Comprehensive test suite with 62 tests

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@coderabbitai
Copy link

coderabbitai bot commented Dec 8, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

Introduces a new MikroORM integration package for NestJS Query ecosystem. Adds complete implementation with NestJS dynamic module, query service supporting CRUD, filtering, sorting, relations, and soft-delete operations, filter query builder for query translation, comprehensive test suite, and supporting configuration files.

Changes

Cohort / File(s) Summary
GitHub Actions & Workflow
.github/workflows/publish-preview.yml
New workflow triggered on pull requests and manual dispatch to build all projects and publish preview packages. Sets NX_BRANCH and NX_RUN_GROUP environment variables.
Root Package Dependencies
package.json
Added three MikroORM dev dependencies: @mikro-orm/core, @mikro-orm/nestjs, @mikro-orm/sqlite.
Package Configuration
packages/query-mikroorm/package.json, packages/query-mikroorm/project.json
Added package manifest with metadata, dependencies (lodash.omit, tslib), peer dependencies (MikroORM, NestJS), and entry points. Added Nx project configuration with build, lint, test, version, and publish targets.
TypeScript Configuration
packages/query-mikroorm/tsconfig.json, packages/query-mikroorm/tsconfig.lib.json, packages/query-mikroorm/tsconfig.spec.json
Added root tsconfig with project references, library tsconfig for CommonJS output and declarations, and spec tsconfig for test environment setup.
Jest Configuration
packages/query-mikroorm/jest.config.ts
Added Jest configuration with ts-jest transformer, node test environment, and coverage directory settings.
Test Fixtures & Seeds
packages/query-mikroorm/__tests__/__fixtures__/*
Created fixture entities (TestEntity, TestRelation, TestSoftDeleteEntity), connection helper with SQLite in-memory setup, and seed utilities for populating test data.
Module & Provider Setup
packages/query-mikroorm/src/module.ts, packages/query-mikroorm/src/providers.ts, packages/query-mikroorm/src/index.ts
Added NestJS dynamic module (NestjsQueryMikroOrmModule) with forFeature method, factory providers for creating query service instances, and public API re-exports.
Query & Filter Logic
packages/query-mikroorm/src/query/filter-query.builder.ts, packages/query-mikroorm/src/query/index.ts
Implemented FilterQueryBuilder for translating NestJS Query DSL to MikroORM query syntax, supporting filters, sorting, paging, nested relations, and operator mapping.
Query Service Implementation
packages/query-mikroorm/src/services/mikroorm-query.service.ts, packages/query-mikroorm/src/services/index.ts
Implemented comprehensive MikroOrmQueryService with CRUD operations, aggregation, soft-delete support, relation management (query, count, add, set, remove), and optional custom filter builder.
Test Suite
packages/query-mikroorm/__tests__/*.spec.ts, packages/query-mikroorm/__tests__/query/*.spec.ts, packages/query-mikroorm/__tests__/services/*.spec.ts
Added unit tests for module creation, provider generation, filter query builder (filters, sorting, paging), and query service operations including CRUD, relations, soft-delete, and aggregations.

Sequence Diagram

sequenceDiagram
    participant App as NestJS App
    participant Module as NestjsQueryMikroOrmModule
    participant Provider as QueryService<br/>Provider
    participant Service as MikroOrmQueryService
    participant FQB as FilterQueryBuilder
    participant Repo as MikroORM<br/>Repository
    participant DB as SQLite DB

    App->>Module: forFeature([Entity])
    Module->>Provider: createMikroOrmQueryServiceProviders
    Provider->>Repo: getRepositoryToken(Entity)
    Module->>App: returns DynamicModule

    App->>Service: inject MikroOrmQueryService
    
    App->>Service: query(QueryDSL)
    Service->>FQB: buildQuery(QueryDSL)
    FQB->>FQB: buildFilter + buildSorting
    FQB-->>Service: { where, options }
    
    Service->>Repo: find(where, options)
    Repo->>DB: execute query
    DB-->>Repo: results
    Repo-->>Service: [Entities]
    Service-->>App: [Entities]
Loading

Estimated Code Review Effort

🎯 4 (Complex) | ⏱️ ~45 minutes

  • MikroOrmQueryService (src/services/mikroorm-query.service.ts): Dense implementation with 20+ methods covering CRUD, aggregation, soft-delete detection, and relation operations. Requires careful review of error handling and soft-delete logic.
  • FilterQueryBuilder (src/query/filter-query.builder.ts): Complex query translation logic with operator mapping, nested relation field detection, and sorting with nulls handling. Multiple recursive and helper functions need verification.
  • Test fixtures and seed logic: Fixture entities use MikroORM decorators extensively; seed function establishes multi-phase data relationships requiring attention to ordering and flushing.
  • Soft-delete implementation: Both in query filtering and CRUD operations; verify consistent behavior across all affected methods.
  • Relation handling: Multiple overloaded methods for querying, counting, and modifying relations; batch processing logic must be traced.

Poem

🐇 A MikroORM garden now grows,
With query builders and relations in rows,
From fixtures to filters, each test is a delight,
Soft-delete flowers bloom soft and bright,
The nestjs-query hutch expands far and wide! 🌱

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4c5a767 and 4ccb963.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (24)
  • .github/workflows/publish-preview.yml (1 hunks)
  • package.json (1 hunks)
  • packages/query-mikroorm/__tests__/__fixtures__/connection.fixture.ts (1 hunks)
  • packages/query-mikroorm/__tests__/__fixtures__/seeds.ts (1 hunks)
  • packages/query-mikroorm/__tests__/__fixtures__/test-relation.entity.ts (1 hunks)
  • packages/query-mikroorm/__tests__/__fixtures__/test-soft-delete.entity.ts (1 hunks)
  • packages/query-mikroorm/__tests__/__fixtures__/test.entity.ts (1 hunks)
  • packages/query-mikroorm/__tests__/module.spec.ts (1 hunks)
  • packages/query-mikroorm/__tests__/providers.spec.ts (1 hunks)
  • packages/query-mikroorm/__tests__/query/filter-query.builder.spec.ts (1 hunks)
  • packages/query-mikroorm/__tests__/services/mikroorm-query.service.spec.ts (1 hunks)
  • packages/query-mikroorm/jest.config.ts (1 hunks)
  • packages/query-mikroorm/package.json (1 hunks)
  • packages/query-mikroorm/project.json (1 hunks)
  • packages/query-mikroorm/src/index.ts (1 hunks)
  • packages/query-mikroorm/src/module.ts (1 hunks)
  • packages/query-mikroorm/src/providers.ts (1 hunks)
  • packages/query-mikroorm/src/query/filter-query.builder.ts (1 hunks)
  • packages/query-mikroorm/src/query/index.ts (1 hunks)
  • packages/query-mikroorm/src/services/index.ts (1 hunks)
  • packages/query-mikroorm/src/services/mikroorm-query.service.ts (1 hunks)
  • packages/query-mikroorm/tsconfig.json (1 hunks)
  • packages/query-mikroorm/tsconfig.lib.json (1 hunks)
  • packages/query-mikroorm/tsconfig.spec.json (1 hunks)

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@jtomaszewski
Copy link
Contributor Author

Sorry, this was meant to be towards my repo.

I'll submit a PR here once it's ready.

@TriPSs
Copy link
Owner

TriPSs commented Dec 8, 2025

@jtomaszewski cool!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants