My FeedDiscussionsHeadless CMS
New
Sign in
Log inSign up
Learn more about Hashnode Headless CMSHashnode Headless CMS
Collaborate seamlessly with Hashnode Headless CMS for Enterprise.
Upgrade ✨Learn more

How to handle Database connections in MONGO-GRAPHQL-MONGOOSE-NODE

Milton Akash's photo
Milton Akash
·Dec 3, 2017

I am developing an app using the above techs. I have a doubt about handling mongodb connections. Which one is the best

  1. Create Mongooose connection on beginnning and use it
  2. Create connection for each resolve and close it inside
  3. Or anything better