Today, we have many options to work with MongoDB, from in-house services to hosting companies that provide Platform as a Service (PaaS) and Software as a Service (SaaS).
We will present a solution called Database as a Service (DbaaS) that provides database services for highly scalable web applications.
Here's a simple step-by-step process to start using a MongoDB instance with a cloud service:
Go to https://www.compose.io/.
Create your free account.
On your dashboard panel, click on add Database.
On the right-hand side, choose Sandbox Database.
Name your database as
node-api
.Add a user to your database.
Go back to your database title, click on admin.
Copy the connection string.
The string connection looks like this:
mongodb://<user>:<password>@kahana.mongohq.com:10073/node-api.
Let's edit the server.js
file using the following steps:
Place your own connection string to the
Mongoose.connect()
function.Open your terminal and input the command:
nodemon server.js
Open...