Skip to content

Improve MongoDB Connection Handling #171

@Renzo-codespace

Description

@Renzo-codespace

Improve MongoDB Connection Handling:

  • Import MongoClient from the mongodb package ONLY ONCE in the ENTIRE PROJECT
  • Instantiate an instance of the client ONLY ONCE in the ENTIRE PROJECT
  • Instantiate the client at the TOP LEVEL of the module, NEVER IN A FUNCTION that returns an instance of the client
  • Import the client instance to other modules ONLY in your DATABASE LAYER
  • NEVER import the client instance to your API MODULES; ONLY import the FUNCTIONS from the database layer
  • NEVER import the client into any COMPONENTS OR PAGES; ONLY FUNCTIONS from the database layer or CREATE CALLS to the API layer
  • Database layer functions in components or pages MUST ONLY EVER RUN AS SERVER-SIDE CODE

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions