Chapter 8. The server database

 

This chapter covers

  • The role of the database in an SPA
  • Using JavaScript as the database language with MongoDB
  • Understanding the Node.js MongoDB driver
  • Implementing CRUD operations
  • Using JSV for data validation
  • Pushing data changes to the client with Socket.IO

This chapter builds on code we’ve written in chapter 7. We recommend copying the entire directory structure for that chapter into a new “chapter_8” directory and updating the files there.

In this chapter, we add the database to our SPA for persistent data storage. This completes our vision of using JavaScript end-to-end—on the database, the server, and the browser. When we’re finished, we’ll be able to start our Node.js server application and invite our friends to sign in to the SPA with their computer or touch device. They can then chat with each other or make changes to avatars that everyone can see in near-real time. Let’s get started by looking more closely at the role of the database.

8.1. The role of the database

We use the database server to provide reliable, persistent storage of data. We rely on the server for this role because data stored on the client is transitory and prone to application errors, user error, and user tampering. Client-side data is also difficult to share peer-to-peer and is available only when the client is online.

8.1.1. Select the data store

8.2. An introduction to MongoDB

 
 
 

8.3. Use the MongoDB driver

 
 

8.4. Validate client data

 
 
 

8.5. Create a separate CRUD module

 
 
 

8.6. Build the Chat module

 
 

8.7. Summary

 
sitemap

Unable to load book!

The book could not be loaded.

(try again in a couple of minutes)

manning.com homepage
test yourself with a liveTest