Hi,
I am working on an application that tracks medication, dosage, prescription, renewal dates etc, I am using MongoDB and trying to use the MongoDB Go Driver.
The issue I am having is that every example I can find online to use this driver does everything in the main func, whereas my app will need to manage the data in the handler funcs for a Web server. I am struggling to see how to keep the connection open when it is opened in the main func so I can just add in the data, search it, update or delete later on. I would rather not create a global variable, though i will if there is no other real choice. I have currently got it working by opening and closing the connection every time I need to reference the database. For small amounts, this isn’t too much of an issue, overhead-wise, however as data entry requirements increase, this will become a problem. Does anyone know the best way to manage this? or can point me to a resource that could show me how to do this?
Appreciate any advice on this, as I am fairly new to working with Mongo.
Dan