Chapter 8

Accessing Databases

IN THIS CHAPTER

Bullet Starting out with MongoDB

Bullet Using the MongoDB shell

Bullet Using MongoDB from Node.js

“If there can be three certain things in life, instead of two, it might be death, taxes, and data.”

—CLARA SHIH

Connecting to databases from Node.js gives your programs the ability to access and store large amounts of persistent data. Most server-side programs make use of some kind of database. These are some uses for server-side databases:

  • Storing user login information and user profiles
  • Storing content for dynamically generating web pages
  • Keeping track of user session information
  • Storing ecommerce product and order information

In this chapter, I show you how to work with one of the most commonly used databases for server-side applications: MongoDB.

Getting Started with MongoDB

The job of any database is to store data in some organized way and make it possible to retrieve that data. One way to classify different types of databases is by how they store data (and how you get that data out of the database). Most databases fall into one of these two broad categories:

  • Relational databases: Relational databases (such as MySQL and Microsoft SQL Server) store ...

Get JavaScript All-in-One For Dummies 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.