all components of the application (handlers) interact with the database separately. The problems associated with this:
Not reusing the connection.
Frequent connect-disconnect cycles to the database.
Redundant codebase and associated issues
all calls need to establish a connection.
repeated access to environment variables and need to assign default cases. Even Minor change requires edit in multiple files that essentially do the same thing.
set configurations ({useUnifiedTopology:true, ...}) in multiple places. Difficult to ship updates or fix bugs as all calls have separate behavior if configurations do not match.
Describe the solution you'd like
a central provider that contains and exports all database operations that the entire project uses.
this would fix the problems mentioned in the current implementation.
Describe alternatives you've considered
we could rely on some ORM like mongoose, but considering that we're using only basic operations in the database, using an ORM like mongoose will slow down the application.
Additional context
This will also provide a method to implement the requested features in #82
Current design
all components of the application (handlers) interact with the database separately. The problems associated with this:
{useUnifiedTopology:true, ...}
) in multiple places. Difficult to ship updates or fix bugs as all calls have separate behavior if configurations do not match.Describe the solution you'd like
Describe alternatives you've considered
Additional context