question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Request scoped connections

See original GitHub issue

I’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:closed
  • Created 4 years ago
  • Reactions:5
  • Comments:16 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
kamilmysliwieccommented, May 13, 2020

It looks great at first sight 😃 @adriano-di-giovanni Think about writing an article about it, I think many people would be interested!

2reactions
aneudysamparocommented, Jul 27, 2019

@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 Module

I’d like to use just NestJS MongooseModule with custom provider (scope)

What do you think?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found