Mongo config - mongo.json

Just like in the HealthcheckProvider, there is a convention to have a unique config file for each of the Providers. As such, we need to add a new mongo.json file inside of the Config folder of our project, which will contain the url of the mongodb instance we want to connect to. In our case, the JSON file will look like this:

{  "url": "mongodb://<db-user>:<db-password>@<host>:<port>/<database>"}

We will get rid of <db-user> and <db-password>, since we do not have those set for our local instance, to quickly get started; however, for production databases, you will have credentials to access the database for security. For host, we will replace it with localhost, since we have mongodb running locally; for port, we will ...

Get Hands-On Full-Stack Development with Swift now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.