Request scoped connections
See original GitHub issueI’m submitting a…
[ ] Regression
[ ] Bug report
[x] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.
Current behavior
The connection is created as a singleton
Expected behavior
The connection options support scope
(https://docs.nestjs.com/fundamentals/injection-scopes) to be defined as per request.
What is the motivation / use case for changing the behavior?
I’d like to open an isolated connection on every HTTP requests.
Environment
Nest version: 6.1.2
Issue Analytics
- State:
- Created 4 years ago
- Reactions:5
- Comments:16 (3 by maintainers)
Top Results From Across the Web
Request Scope - Oracle Help Center
Request scope can be especially useful for components whose properties are set by a form. When a form is submitted, the component values...
Read more >Injection scopes | NestJS - A progressive Node.js framework
We have a connection pool to the database, singleton services with global state, ... For a request-scoped controller, a new instance is created...
Read more >javascript - Request-Scoped Services - Stack Overflow
In that case, a new instance of RequestContext class will be created for every request. So, you can store any request-scope information inside ......
Read more >Using the Spring Web Scopes, Part 1 - Manning Publications
In this section, you learn how to use request-scoped beans in Spring web apps. Web apps are focused on HTTP requests and responses....
Read more >4.4 Bean scopes - Spring
Scopes a single bean definition to the lifecycle of a single HTTP request; that is each and ... but also the wiring up...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
It looks great at first sight 😃 @adriano-di-giovanni Think about writing an article about it, I think many people would be interested!
@DenisPalchuk I think this may depends on the case! For me I’d like to use a different DB depending on the request (subdomain). Just trying to make a multi-tenancy app based on domain/subdomain names.
currently i could this make it work but using MongooseModule and mongoose lib per-sé, which I think is a big force!
Check this! Database Provider - set database dynamically based on subdomain using just mongoose
But here in same project i used NestJS MongooseModule because it doesn’t have
scope
to provide REQUEST object. Tenant ModuleI’d like to use just NestJS MongooseModule with custom provider (
scope
)What do you think?