arashsheyda / nuxt-mongoose

A Nuxt module for simplifying the use of Mongoose in your project.
https://docs.arashsheyda.me/nuxt-mongoose
75 stars 13 forks source link

Connect to MongoDB lazy #33

Open MickL opened 10 months ago

MickL commented 10 months ago

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:

arashsheyda commented 10 months ago

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

jankaderabek commented 10 months ago

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 commented 9 months ago

@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