Book Image

Web Development with MongoDB and Node.js

By : Jason Krol
Book Image

Web Development with MongoDB and Node.js

By: Jason Krol

Overview of this book

Table of Contents (19 chapters)
Web Development with MongoDB and Node.js
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
12
Popular Node.js Web Frameworks
Index

Chapter 7. Persisting Data with MongoDB

With almost any application written for the Web nowadays, a highly interactive application is of limited value if the interactions of its users aren't permanently saved. The most common way to handle this requirement is with a database that permanently saves data to the filesystem. Imagine a world where all of the data for your application (registered users, order transactions, and social interactions) were all stored within the temporary memory of the server the application is running on. The moment that server is turned off or rebooted, all of your application that would be lost. Relying on a database to store this data permanently is crucial to the success of any dynamic application.

In this chapter, the following topics will be covered:

  • Connecting to MongoDB

  • An introduction to Mongoose

  • Schemas and models

  • Adding CRUD to our controllers

In the previous chapter, we wrote and accounted for the actual logic of our application. The next step in building our...