O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using MongoDB with Node.js

Video Description

Using MongoDB with Node.js is the fourth title in Wes Higbee's explanation of all things Node. This course details how to store data - as documents - coming from your JavaScript apps into MongoDB.

There are two popular approaches to interacting with MongoDB: The native driver and Mongoose. In this video, you'll learn about both of these, when to pick one over the other, and something else equally important (and often neglected): How to write maintainable asynchronous MongoDB communications code. Web app developers with a strong command of JavaScript, those wanting to incorporate server-side programming into their development, and those wanting to better understand NoSQL database technology will appreciate this step-by-step guide to using MongoDB with Node.js. Working files are included, allowing you to follow along with the author throughout the lessons.

  • Understand how the native Node.js MongoDB driver works
  • Learn to use the Mongoose ODM to communicate with a MongoDB server
  • Compare asynchronous coding styles: callbacks, promises, generators and async/await
  • Learn how to serialize JS objects to documents stored in MongoDB.
  • Explore basic CRUD operations with MongoDB.
  • Practice debugging, error handling, logging, and monitoring.

Table of Contents

  1. MongoDB
    1. Welcome 00:08:23
    2. About The Author 00:01:23
    3. The Sample Application 00:05:31
    4. JSON Analogy 00:04:01
    5. SQL Vs DocumentDB 00:07:48
    6. Running MongoDB Locally 00:03:01
    7. Connecting With Mongo CLI 00:03:13
    8. Robomongo 00:01:49
    9. Inserting Documents 00:03:30
    10. Objectids 00:00:42
    11. Inserting Users 00:07:49
    12. How To Access Your Working Files 00:01:15
  2. The Native Driver
    1. MongoDB Node.js Native Driver 00:04:51
    2. Inserting Documents From Node.js 00:02:47
    3. DB.Close() 00:01:06
    4. Querying Rooms 00:07:10
    5. Create Rooms 00:02:02
    6. Deleting Rooms 00:07:09
    7. Finding A Room By ID 00:05:10
    8. Replacing Documents 00:05:27
    9. Handling Errors 00:03:40
  3. Sanity With Promises
    1. Why Promises 00:01:04
    2. Connect With Promises 00:06:07
    3. Querying With Promises 00:02:27
    4. Promise Control Flow Debugging 00:03:10
    5. Simplify Error Handling With Promises 00:04:05
    6. Promises Handle Throws Too 00:01:58
    7. Promises Cache DB Connection 00:03:53
    8. Chaining Promises To Further Simplify 00:04:44
    9. Extracting A ChatDB Module 00:04:22
    10. Converting From Callbacks To Promises Part - 1 00:05:36
    11. Converting From Callbacks To Promises Part - 2 00:02:57
    12. Benefits Of Refactoring Callbacks To Promises 00:01:53
    13. Gracefully Closing DB Connections 00:03:03
    14. Promises Plus Generators With co 00:04:26
    15. co-express 00:03:37
    16. EsS016 Async Await 00:05:47
  4. Getting Started With Mongoose
    1. Mongoose 00:02:47
    2. Importing Users With Mongoose 00:09:13
    3. Collection Names 00:01:46
    4. Disconnect 00:00:47
    5. Strict Mode Throw And Overriding Mongoose Promises 00:03:44
    6. Strict Mode False To Allow Extra Fields 00:01:36
    7. Schema Conversion And Validation 00:02:22
    8. Finishing The User Schema 00:01:50
  5. Mongoose With Express
    1. Extracting A User Model Module 00:04:47
    2. Querying Users 00:03:25
    3. Connect Once With Mongoose 00:02:20
    4. Debugging Models 00:01:09
    5. Creating Users 00:03:20
    6. Finding A User By ID 00:03:27
    7. Saving User Changes 00:02:21
    8. Delete Users 00:02:21
    9. Decouple Mongoose Connect 00:06:50
    10. Catching Errors 00:02:16
    11. Showing Validation Errors 00:07:16
    12. Further Validation 00:05:13
  6. Grab Bag
    1. Filtering Documents 00:07:02
    2. Using Query Operators 00:03:15
    3. Native Driver Logging 00:07:09
    4. Mongoose Logging 00:02:28
    5. Partial Update With $Set 00:03:55
    6. Unset And Rename 00:01:37
    7. To Replace Or Update 00:02:21
    8. Sriracha For Automatic Admin Portals 00:06:22
    9. Everything Is A Document 00:03:24
    10. Further Learning 00:08:19
    11. Challenge 00:02:38