Book Image

Learning Single-page Web Application Development

Book Image

Learning Single-page Web Application Development

Overview of this book

Table of Contents (15 chapters)
Learning Single-page Web Application Development
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Using MongoDB in the cloud


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:

  1. Go to https://www.compose.io/.

  2. Create your free account.

  3. On your dashboard panel, click on add Database.

  4. On the right-hand side, choose Sandbox Database.

  5. Name your database as node-api.

  6. Add a user to your database.

  7. Go back to your database title, click on admin.

  8. Copy the connection string.

  9. 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:

  1. Place your own connection string to the Mongoose.connect() function.

  2. Open your terminal and input the command:

    nodemon server.js
    
  3. Open...