Creating a MongoDB instance for our app
We have already seen how to start with the MongoDB setup in Chapter 2, Setting Up the Document Store with MongoDB. Now, I will just say that we need to create a new database – I will call mine carsApp
– and, inside of it, a collection, which I will aptly name cars1
. I assume that you have followed the procedure outlined in Chapter 2, Setting Up the Document Store with MongoDB, you have defined a database user with a username and password, and you have allowed all possible IP addresses to connect to it. This is not the most secure way of working with MongoDB, nor is it recommended, but for our purposes it will simplify the workflow. The next step is getting our connection string information and keeping it somewhere safe. For now, I will keep them in a handy text file in the following format:
DB_URL = "mongodb+srv://<dbName>:<dbPassword>@cluster0.fkm24.mongodb.net/?retryWrites=true&w=majority" DB_NAME...