Skip to content

feat(mongoose): export base Connection and Collection classes#15548

Merged
vkarpov15 merged 1 commit into8.17from
vkarpov15/export-base-connection-and-collection
Jul 24, 2025
Merged

feat(mongoose): export base Connection and Collection classes#15548
vkarpov15 merged 1 commit into8.17from
vkarpov15/export-base-connection-and-collection

Conversation

@vkarpov15
Copy link
Collaborator

Summary

Right now the Mongoose global doesn't export the base Connection and Collection classes, which makes things tricky for drivers looking to integrate against the base Connection and Collection classes without the node-mongodb-native driver. That's because import { Connection } from 'mongoose'; triggers lib/index.js's setDriver() call, and Connection is just a getter around the current driver's Connection, so there's no way to get the base Connection class without importing mongoose/lib/connection.

Examples

@vkarpov15 vkarpov15 added this to the 8.17 milestone Jul 24, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds exports for the base Connection and Collection classes to the Mongoose global object to enable drivers to integrate against these base classes without importing the node-mongodb-native driver. The change addresses the issue where importing { Connection } from 'mongoose' triggers setDriver() and returns the current driver's Connection rather than the base class.

  • Exports BaseConnection and BaseCollection classes on the Mongoose prototype
  • Adds TypeScript test coverage for the new base class exports

Reviewed Changes

Copilot reviewed 2 out of 4 changed files in this pull request and generated 2 comments.

File Description
lib/mongoose.js Adds BaseConnection and BaseCollection exports with JSDoc documentation
test/types/base.test.ts Adds TypeScript test to verify base class exports work correctly

@hasezoey hasezoey added the typescript Types or Types-test related issue / Pull Request label Jul 24, 2025
@vkarpov15 vkarpov15 changed the base branch from master to 8.17 July 24, 2025 15:35
@vkarpov15 vkarpov15 merged commit 73edf53 into 8.17 Jul 24, 2025
110 of 111 checks passed
@vkarpov15 vkarpov15 deleted the vkarpov15/export-base-connection-and-collection branch July 24, 2025 15:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

typescript Types or Types-test related issue / Pull Request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants