Skip to content

refactor(mongo)!: remove deprecated getMongoRepository and getMongoManager globals#12099

Merged
pkuczynski merged 1 commit intomasterfrom
remove-mongo-globals
Mar 5, 2026
Merged

refactor(mongo)!: remove deprecated getMongoRepository and getMongoManager globals#12099
pkuczynski merged 1 commit intomasterfrom
remove-mongo-globals

Conversation

@pkuczynski
Copy link
Copy Markdown
Member

@pkuczynski pkuczynski commented Mar 5, 2026

Remove the deprecated global functions getMongoRepository() and getMongoManager() from src/globals.ts, along with their now-unused MongoRepository and MongoEntityManager imports.

Instance methods on DataSource and EntityManager are unaffected.

Closes #12078

Part of #11603.

@pkuczynski pkuczynski self-assigned this Mar 5, 2026
@qodo-free-for-open-source-projects
Copy link
Copy Markdown

Review Summary by Qodo

Remove deprecated MongoDB global functions from globals.ts

✨ Enhancement

Grey Divider

Walkthroughs

Description
• Remove deprecated getMongoRepository() and getMongoManager() global functions
• Remove unused MongoRepository and MongoEntityManager type imports
• Update documentation with migration guidance for DataSource methods
• Update MongoDB driver example to use instance methods
Diagram
flowchart LR
  A["Deprecated globals<br/>getMongoRepository<br/>getMongoManager"] -->|removed| B["Use DataSource<br/>instance methods"]
  C["Type imports<br/>MongoRepository<br/>MongoEntityManager"] -->|removed| D["Cleaner imports"]
  E["Documentation<br/>examples"] -->|updated| F["Migration guide<br/>added"]
Loading

Grey Divider

File Changes

1. src/globals.ts ✨ Enhancement +0/-30

Remove MongoDB deprecated global functions

• Removed MongoRepository and MongoEntityManager type imports
• Deleted getMongoManager() deprecated global function
• Deleted getMongoRepository() deprecated global function
• Preserved all other repository and manager getter functions

src/globals.ts


2. docs/docs/drivers/mongodb.md 📝 Documentation +1/-4

Update MongoDB example to use DataSource

• Removed getMongoManager() import statement from example
• Updated code example to use myDataSource.manager.save() instead of deprecated global
• Simplified MongoDB usage pattern in documentation

docs/docs/drivers/mongodb.md


3. docs/docs/guides/8-migration-v1.md 📝 Documentation +16/-0

Add migration guide for MongoDB globals

• Added new migration section for removed MongoDB globals
• Provided before/after code examples showing migration path
• Documented replacement using dataSource.mongoManager and dataSource.getMongoRepository()

docs/docs/guides/8-migration-v1.md


Grey Divider

Qodo Logo

@qodo-free-for-open-source-projects
Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (1) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider


Remediation recommended

1. Docs: manager vs mongoManager 🐞 Bug ✓ Correctness
Description
mongodb.md now replaces getMongoManager() with myDataSource.manager.save(user), but the
migration guide recommends dataSource.mongoManager. Both work at runtime, but manager is typed
as EntityManager, so TS users lose MongoEntityManager typing/autocomplete for Mongo-specific APIs
and the docs become inconsistent.
Code

docs/docs/drivers/mongodb.md[205]

+await myDataSource.manager.save(user)
Evidence
The updated MongoDB docs use myDataSource.manager, but DataSource.manager is declared as
EntityManager (generic). TypeORM provides DataSource.mongoManager specifically to expose
MongoEntityManager typing, and the migration guide already documents it as the replacement for
getMongoManager(). manager.save() still works because EntityManager.save() is generic and
executes via EntityPersistExecutor, and for MongoDB the runtime manager instance is created as
MongoEntityManager.

docs/docs/drivers/mongodb.md[190-206]
src/data-source/DataSource.ts[83-87]
src/data-source/DataSource.ts[165-179]
src/entity-manager/EntityManagerFactory.ts[16-24]
src/entity-manager/EntityManager.ts[443-480]
docs/docs/guides/8-migration-v1.md[146-160]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`docs/docs/drivers/mongodb.md` now demonstrates saving via `myDataSource.manager.save(user)` after removing the `getMongoManager()` global. While this works, it’s inconsistent with the migration guide and drops MongoDB-specific typing/autocomplete because `DataSource.manager` is declared as `EntityManager`.

### Issue Context
TypeORM provides `DataSource.mongoManager` specifically to expose `MongoEntityManager` typing for MongoDB connections.

### Fix Focus Areas
- docs/docs/drivers/mongodb.md[190-206]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

ⓘ The new review experience is currently in Beta. Learn more

Grey Divider

Qodo Logo

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Mar 5, 2026

commit: 54b4623

@pkuczynski pkuczynski merged commit 67fbe7c into master Mar 5, 2026
15 checks passed
@pkuczynski pkuczynski deleted the remove-mongo-globals branch March 5, 2026 17:51
@pkuczynski pkuczynski added this to the 1.0 milestone Mar 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants