Saturday 18 May 2019

When using MongoDB, is it normal to use MongoClient.connect() a lot?

I thought I could call it once and then use collection.find() and whatever else I need when I need it, but it looks like I have to connect to MongoClient every time I interact with the database.Am I supposed to connect once and have a sort of global declaration of the database connection, or am I supposed to connect almost every time I'm interacting with the database?

Submitted May 18, 2019 at 01:12PM by WarAndGeese

No comments:

Post a Comment