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

Connect to MongoDB lazy #33

Open
MickL opened this issue Nov 25, 2023 · 3 comments
Open

Connect to MongoDB lazy #33

MickL opened this issue Nov 25, 2023 · 3 comments
Labels
enhancement New feature or request PR welcome

Comments

@MickL
Copy link

MickL commented Nov 25, 2023

Hello,
right now it seems like a connection to MongoDB is established when the Nuxt app starts. But when the app is deployed as a serverless function maybe a server handler is called that doesnt require any MongoDB connection. In this case the start of the app is delayed even tho MongoDB isnt even needed for the incoming request.

Is it possible to only connect to MongoDB when a query is executed?

For example:

  • GET api/cats -> returns data from a third party service -> No MongoDB connection is established
  • GET api/dogs -> calls model Dog.find() —> Now a MongoDB connection gets established
@arashsheyda
Copy link
Owner

@MickL that's a pretty good idea! for sure it would be nice. thanks

@arashsheyda arashsheyda added the enhancement New feature or request label Nov 27, 2023
@jankaderabek
Copy link

I want to upvote this, it's something I just wanted to ask about 😀 Is there some way we could help with it? Do you have some idea how you would like to implement it?

@arashsheyda
Copy link
Owner

@jankaderabek I tought if we could find the right hook for nitr it's possible but I couldn't find any to work, so I'm kinda stuck

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request PR welcome
Projects
None yet
Development

No branches or pull requests

3 participants