From the course: MongoDB Essential Training

Unlock the full course today

Join today to access over 23,200 courses taught by industry experts.

Connecting with JavaScript

Connecting with JavaScript - MongoDB Tutorial

From the course: MongoDB Essential Training

Connecting with JavaScript

- If you are using node.js, there are two main drivers that you can use, the MongoDB supported driver, which you'll find behaves similarly to the MongoDB shell, and Mongoose, which is an object modeling tool for MongoDB. A lot of people choose to use Mongoose over MongoDB's driver because it removes some extra code you need to write, like opening and closing connections. However, it is worth noting that Mongoose may be a bit slower than the native driver, and that it forces you to declare schemas, which Mongo DB's driver doesn't do. For this video, we will be using Mongoose. Alright, inside this folder, I've already got two files, an index.js file and a package.json file. Let me show you what's inside the package.json file for right now. Okay. Now, to install Mongoose, I'm going to run NPM install mongoose--save. I am also going to install the dotenv package. That will allow us to use environment variables. Okay…

Contents