Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there a way to apply mongoose plugin after connection is created #179

Closed
NenadJovicic opened this issue Dec 2, 2019 · 1 comment
Closed
Labels

Comments

@NenadJovicic
Copy link

I'm submitting a...


[ ] Regression 
[ ] Bug report
[ ] Feature request
[x] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

I am using mongoose plugin which depends on mongoose.connection
As I wrote in some other issues (#27 and #109) there was a problems after nest upgrade from 4 to 6 because you started to use createConnection() instead of connect().

Expected behavior

To have an option to get connection before models are initialized. Would be good to have it in MongooseModule.forRoot() or MongooseModule.forRootAsync() or somewhere else

Plugin that I am using is mongoose-id-validator which was using mongoose.connection to instance a model and search for a reference that I have in Document. I had to change this plugin after upgrading nest

My question is, is there some official way of getting connection that nest establish to mongo, after it is created, but before models are generated with MongooseModule.forFeature (plugins can't be applied on models that are already initialized), because plugin that I am using got as an option to provide a connection that should be used.

Minimal reproduction of the problem with instructions

What is the motivation / use case for changing the behavior?

Described in Current behavior

Environment


Nest version: 6.8.5

 
For Tooling issues:
- Node version: XX  
- Platform:  

Others:

@kamilmysliwiec
Copy link
Member

Let's track this here nestjs/docs.nestjs.com#938

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants